Germany's domestic intelligence chief, Hans-Georg Maassen, has been told to quit and move to a senior post at the interior ministry.
The government decision came amid a row over Mr Maassen's response to far-right unrest in Chemnitz, eastern Germany.
Anti-migrant "hunts" were reported there on 26 August after a German man was killed in a brawl with migrants.
Mr Maassen doubted that foreign-looking people had been hounded. Chancellor Angela Merkel was urged to sack him.
Critics said his scepticism downplayed the seriousness of far-right violence and intimidation in Chemnitz.
Mr Maassen will leave the BfV spy service and become a state secretary in the interior ministry. German media report that he will actually move to a higher pay grade. It is not yet clear who will replace him.
What happened in Chemnitz?
Several xenophobic assaults were reported in the eastern city after the fatal stabbing of Daniel Hillig. They were described as racist "hunts", and images emerged showing demonstrators chasing people and flinging bottles and fireworks.
Controversially, spy chief Mr Maassen said his Federal Office for Constitutional Protection (BfV) - which is similar to the British MI5 - had "no reliable information about such hunts taking place" in Chemnitz.
He also questioned whether a video posted by "Antifa Zeckenbiss" - meaning "anti-fascist tick bite" - really showed, as claimed, a "hunt in Chemnitz" on 26 August.
Mr Maassen said the video could have been disinformation; he added that he did not know who was behind Antifa Zeckenbiss.
German public broadcaster ARD said in a "fact-check" that Antifa Zeckenbiss is an anonymous Twitter account, active since February, posting anti-fascist messages and "there is nothing to indicate that it is a fake account".
There were more far-right rallies in Chemnitz after 26 August, and smaller counter-demonstrations by leftists.
Mr Maassen was also criticised over his contacts with far-right Alternative for Germany (AfD) politicians.
Who decided to force him out?
Tuesday's decision was a compromise between Mrs Merkel and her coalition partners - Interior Minister Horst Seehofer, of the right-wing Bavarian CSU, and centre-left Social Democrat (SPD) leader Andrea Nahles.
Mr Seehofer defended Mr Maassen's actions over Chemnitz, but Ms Nahles wanted him dismissed.
AfD's Beatrix von Storch tweeted scornfully: "This gives the SPD what it wanted in theory, Seehofer can remain spineless and Merkel gets some peace."
What happened about the stabbing?
Investigations over the murder of Daniel Hillig are ongoing.
Earlier on Tuesday, an Iraqi man identified as Yousif A was released from custody, three weeks after he was arrested and detained over the killing.
His lawyer Ulrich Dost-Roxin said the detention had been "illegal", and accused officials and politicians of using him for political ends. "No witness accused my client of involvement in the crime," he said in a statement.
A Syrian man is still in custody, and police are still looking for a third suspect.
What's the bigger picture?
The Maassen controversy has fuelled fears that Germany's main state security body may be soft on far-right extremism.
AfD is now the main opposition party, with 92 seats in the 709-seat Bundestag. It backs the far-right protests, arguing that violent asylum-seekers should be expelled from Germany.
AfD is furious with Mrs Merkel for having let in more than a million migrants in 2015-2016.
Mr Maassen's predecessor was forced to quit over BfV shortcomings in the notorious NSU neo-Nazi case, in which a terrorist cell killed 10 people in a racially-motivated campaign in 2000-2007. The BfV and police were found to have neglected or ignored racism as a motive.
Who does the BfV spy on?
It has about 3,100 staff who, along with regional intelligence services, monitor groups acting against Germany's democratic order.
It was created in 1950 by the Allied powers in Germany to guard against communist and pro-Nazi groups. It is part of the federal interior ministry and is overseen by the Bundestag.
The BfV cannot make arrests. It says most of its intelligence is gathered from open or public sources, including press reports.
It can only spy on groups - not private individuals - engaged in anti-constitutional behaviour. Separate BfV departments spy on radical left-wingers, far-right extremists and militant Islamists.
The BfV also runs counter-espionage operations, watching foreign spies in Germany. But overseas intelligence-gathering is done by the BND spy service.