Germany cannot decide whether migrants or xenophobes are a bigger threat.

Every so often, one of the Middle Eastern migrants Chancellor Angela Merkel invited to Germany in the autumn of 2015 commits a horrible crime, and headaches for her coalition government ensue. There ought to be nothing surprising about this: About a million and a half people, most of them young men, drifted into Germany after Merkel’s appeal. Even if they committed crime at German rates, you could expect a murder a month and several sexual assaults. But when a 35-year-old local carpenter was stabbed to death at the end of August, allegedly by a pair of Middle Eastern migrants, in the city of Chemnitz, Germans suddenly lost their inclination to take such things in stride. Chemnitz, formerly Karl-Marx-Stadt, filled up with thousands of anti-immigration marchers, some of them making Hitler salutes and harassing foreign-looking people. These incidents were captured on video, and the fallout brought Merkel’s government to the verge of collapse.

Germany has a basic problem. As the columnist Berthold Kohler put it, the country cannot decide whether it has more to fear from Ausländer (foreigners) or Ausländerfeinde (xenophobes). The public is firmly of the former view. The government is invested in the latter. Eventually the public will win, because it has an internal logic and Merkel’s coalition does not. In three out of the four most recent elections, neither of the traditional establishment parties has been able to muster a governing majority. So the two have formed a “grand coalition,” which Merkel has held together by pursuing the agenda of the (once-socialistic) Social Democrats in the name of her own (once-conservative) Christian Democrats. People gave both parties historic drubbings at the polls last fall, with the Social Democrats falling to barely a fifth of the vote. The result was a narrower majority for Merkel, a much bigger role for the Social Democrats (who then had to be bribed with cabinet posts to agree to renew an arrangement that had so damaged them), and a veto on almost all policy for one of the rare conservatives in Merkel’s cabinet, interior minister Horst Seehofer of Bavaria’s Christian Social Union.

Seehofer has powerful allies in the government, and that is what brought about Merkel’s latest crisis.

Native Germans have often felt like an afterthought in the years since Merkel threw open their country’s gates. The post-Chemnitz declaration by her spokesman, Steffen Seibert, did not reassure them. “We don’t tolerate such unlawful assemblies,” Seibert said, “and the hounding of people who look different or have different origins, and attempts to spread hatred on the streets.”

That was a reasonable point, as long as the murder, too, was being kept in mind. Early this month one of Seehofer’s most powerful allies stepped forward to say that it was not. Hans-Georg Maassen had a bone to pick with one viral video that seemed to show non-Germans being hounded. “There is no proof,” he said, “that the video about this alleged incident that’s getting forwarded around the Internet is authentic. There is good reason to think that it is piece of misinformation that aims to distract the public from the murder in Chemnitz.”

Maassen is a gifted investigator on security matters who in the 1990s wrote an impressive, if hardline, dissertation on asylum law. Two years ago he arrested a Syrian refugee named Jaber al-Bakr—in Chemnitz, as it happens—who allegedly plotted to blow up an unnamed transport hub with triacetone triperoxide, or TATP, the same explosive used in the killings in Paris in the autumn of 2015. People well informed about the workings of the interior ministry describe three men there as so out of sympathy with Merkel’s refugee policy that they constitute something like a “resistance,” to use the term beloved of Trump opponents. According to press reports, these are Dieter Romann, chief of the federal police; Gerhard Schindler, former chief of the Bundesnachrichtendienst (Germany’s equivalent of the FBI); and Maassen himself, who since 2012 has been head of the Bundesamt für Verfassungsschutz (BfV).

That was the problem. Verfassungs-schutz means “defense of the constitution.” The BfV is the main law enforcement body responsible for keeping Germany from ever turning fascist again. It has authority to monitor demonstrations, surveil political parties, and infiltrate radical groups. And yet here Maassen was, repeating what sounded like the boilerplate of conspiracy theorists: that outside actors were somehow responsible for the excesses witnessed at right-wing gatherings. It emerged that Maassen had met earlier in the summer with members of the Alternative for Germany (AfD), the new anti-immigrant party that, in large parts of the country, is now more popular than the Social Democrats. Whether out of principle, pride, or panic, the new Social Democrat leader Andrea Nahles told Merkel that Maassen would have to go.

Nahles’s means were not adequate to her ambitions. Maassen could not be forced to go. Seehofer’s Christian Social Union, a strictly Bavarian party, is set to fall well short of a legislative majority in state elections next month. The CSU has always been a right-wing regional pillar of Merkel’s coalition, but the CSU’s voters no longer trust that the party is right-wing enough to defend them against a wave of migrants. They are defecting in droves to the AfD, which now draws 14 percent of the vote in Bavaria to the CSU’s 36. This could present the CSU with a choice between making common cause with the AfD or surrendering power for the first time since the war.

Seehofer’s successor as minister president of Bavaria, Markus Söder, has been trying to win back the Bavarian right with the Kreuzpflicht—a requirement that crucifixes be placed at the entrance of every public building in the traditionally Catholic land, which has been filling up, like the rest of Germany, with Muslim migrants. It doesn’t seem to be working. Söder has also warned that he would put certain members of the AfD under surveillance for extremism. That hasn’t worked, either. Under the circumstances, Seehofer could hardly turn his back on Maassen, one of the few conservatives in the Merkel cabinet.

What a predicament! If Maassen stayed, Nahles would leave the coalition and the government would fall. If Maassen left, Seehofer would leave the coalition and the government would fall. Merkel came up with an extraordinary compromise. Maassen would lose his post at the head of the BfV, but he would receive a new one as a so-called Staatssekretär under Seehofer. This looked like a very clever arrangement, albeit one that gave real concessions to Nahles and only face-saving ones to Seehofer.

That was not how Germans saw it. Really, you’d think it wouldn’t matter much whether people called you Kabinettsangelegenheitenabteilungsleiter or Kabinettsangelegenheitenabteilungs-direktor, but Germans care passionately about the protocol of the organizational pyramid. Staatssekretär turns out to be a plum title. In article after article, you could read that Maassen’s bureaucratic status would be upgraded from B9 to B11, entitling him to a monthly raise from 11,577.13 to 14,157.33 euros.

This fit neither Germans’ expectation of their bureaucracy nor progressives’ expectation that winning a political battle means humiliating and destroying your adversary. B9 to B11! The Social Democrats thought the deal Nahles had negotiated was too clever by half. On September 19, the day after the change was made, the deputy party leader and the leader of the party’s youth wing denounced it. By the next day, even Nahles was attacking the deal made at her insistence. This probably won’t be the last such intracoalition battle.

What most unites the Merkel forces now is their worry that the more radical the AfD gets, the better it seems to do in the polls. This view, which is widely held, is creating a cascade of radicalization across other parties. The less popular the CSU becomes with its voters, the more it must tack away from those who are loyal and towards those who have abandoned it. The less popular the Social Democrats get, the more they feel entitled to make demands in exchange for keeping the Merkel coalition alive. Those who declared in 2015 that Merkel’s welcome to migrants would shape her legacy were correct. It is not looking like the legacy she anticipated.