In the last days of July, German chancellor Angela Merkel rushed back to Berlin from her summer vacation to tell her countrymen how strong they were. She had done the same thing a year earlier, when Europe faced a wave of refugees from the war in Syria, joined by migrants from Iraq, Iran, and elsewhere in the Muslim world. Back in the summer of 2015, Merkel announced that Germany could handle 800,000 of them. Migrants took it as an invitation. Over a million came. The encounter between Germany and its new Muslim population has been rocky. Last New Year’s Eve in downtown Cologne saw 1,200 sexual assaults by mostly migrant men. A Moroccan girl stabbed a policeman in Hannover in March, and in April two teenagers, Yusuf T. and Mohammed B., blew up a Sikh temple in Essen.

At her latest appearance, Merkel professed herself proud of last summer's invitation and told Germans they were now summoned to "a great test in mastering the flipside, the shadow side, of all the positive effects of globalization." This was the chancellor's glass-half-full way of acknowledging that various newcomers to the national household had begun to attack and kill her voters at an alarming rate. On Monday, July 18, a 17-year-old Afghan, armed with an axe and hollering Allahu Akbar!, attacked a family of travelers from Hong Kong on a train. Four days later, on Friday, a German-Iranian named Ali Sonboly ran amok in Munich with a 9mm Glock and 300 rounds of ammunition in a McDonald's full of children and a shopping mall, shooting 29 people, of whom 9 died. That Sunday, in Reutlingen in Baden-Württemberg, a 21-year-old recent Syrian arrival named Mohamed hacked to death a pregnant Polish restaurant employee. At a music festival in Ansbach that same afternoon, another Syrian refugee, 27-year-old Muhammad Daleel, became Germany's first-ever suicide bomber, killing himself and wounding 15.

Germans have been enjoined not to leap to conclusions about the individuals involved. The train axe man and the festival bomber claimed their attacks for ISIS. The machete man knew the woman he killed, so the incident was, news reports reassured, "not terrorism." The mall shooter was a terrorist, true, but his family had arrived from Iran in the 1990s, making it possible to describe the terrorism as "homegrown." Still, all the killers were of a migrant background, and this will do nothing to make Merkel's promotion of migration more popular. Last year's invitation to refugees was the occasion of a lot of German self-congratulation. The country is still relatively optimistic. An early August poll by the Pew Research Center asked people in various European countries how they felt about the European Union's policy on refugees. They hate it. In all of them, the number of people who disapprove is a multiple of the number of those who approve. In Greece, 94 percent are upset, 5 percent content. Germans distrust EU refugee policy by "only" a 2 ½ - 1 ratio. Merkel is lucky. Migration has fallen to a tiny fraction of what it was in 2015—just 57,000 refugees since March.

But with just 14 months to go until she must present herself for reelection, Merkel's luck may be running out. Migration is low partly because Germany (like Sweden, Norway, Denmark, and Austria) has instituted a "temporary" suspension of the EU's Schengen system, which permits unhindered travel across national borders. But the main factor in the migration decline is that Merkel was able to cut a deal with Recep Tayyip Erdogan, president of Turkey, a few months ago. Speaking unofficially for Europe, she made (vague) offers to find places for future Syrian refugees and (specific) offers to convey about $8 billion in aid to Turkey. In return, Turkey promised to dam the human flood that had been pouring across Eurasia since the summer before.

The military coup attempted against Erdogan in July has put the deal in question. Erdogan's allies blame the coup on followers of the exiled Muslim teacher Fethullah Gülen, now holed up in the Poconos. When Erdogan's populist AK party won a shocking victory in 2002, Gülen's well-educated followers helped staff the government—something the AK party alone was in no position to do. But the interests of Erdogan and Gülen never converged. Erdogan's post-coup purge has been ferocious. He has closed 45 newspapers, arrested several dozen journalists from the newspaper Zaman, and revoked 50,000 passports. Whether this is justified or excessive is a question of political taste, and one we can leave for another day. But it complicates matters terribly for Germany. For one thing, Erdogan is not just scrubbing all his country's institutions clean of Gülen supporters—he is calling on his allies for help and belittling those who don't provide it. He wants the United States to extradite Gülen himself. He also wants to keep the large European Gülenite community under surveillance, to investigate its schools, and to extradite its mid-level leaders.

To this end, Turkey is activating supporters in Germany's massive and poorly assimilated Turkish minority. On July 31, a pro-Erdogan group rallied as many as 40,000 people in the center of Cologne, according to police. They waved flags and bellowed their support for the Turkish leader. The Süddeutsche Zeitung columnist Heribert Prantl, in general punctiliously deferential to migrants, described these ones as Jubel-Türken, or Turkish rejoicers, and professed himself alarmed. "To look at the rejoicers is to think of judges, scientists and journalists who are under arrest in Turkey. It gives you goose bumps," he said. Of course, he could be wrong. "Possibly this 'Erdoganitis,' " he suggested, "is just a defiant reaction to Islamophobia."

The coup also raises the question of whether Turkey still qualifies under international law as a "secure third state" to which refugees can be shipped back. As legal matters go, this is a reputational rather than a practical question. Refugees have grown so unpopular throughout Europe that they have arguably, through the Brexit referendum, cost the European Union one of its most important members. There is little chance the European Commission will budge from its claim that Turkey is a perfectly safe place to send refugees back to. The problem is that this claim may grow steadily more at odds with reality.

And that would be embarrassing. European bureaucrats are only ever comfortable talking about migration when they can cast themselves as heroes of human rights. They believe they themselves are the best source of enlightenment that Turkey could ever possibly tap. "The only thing that encourages the democratic development of Turkey," Austrian EU commissioner Johannes Hahn told the Süddeutsche Zeitung, "is the prospect of becoming a member of the European Union." Turkey's moves in recent days to reintroduce the death penalty, which it abolished in 2004, have traumatized the EU's Turkey-watchers.

Paying lip service to human rights allows European officials to pretend that, if they are walling out millions of the wretched of the earth, they are doing so only from the highest of humanitarian motives. "If we want to cut the ground out from under the human traffickers," wrote Elmar Brok, a member of the European parliament for Merkel's Christian Democrats, in the Frankfurter Allgemeine Zeitung, "if we want fewer and—above all—legal migrants to come to Europe, if we want to protect refugees from the risk of boarding rickety boats and drowning in the Mediterranean . . . then we need this deal." Of course, this is a piety. The migration deal with Turkey is not meant to keep migrants from drowning. It is meant to keep migrants from migrating.

Younger members of Merkel's own Christian Democrats are losing patience with her migration and multicultural policy. Jens Spahn, 36, a gay civil libertarian who rose as a protégé of finance minister Wolfgang Schäuble, calls himself a "burka-phobe," a remark no Christian Democrat would have made even in jest a few years ago. The Alternative for Germany party, which has shifted its focus from monetary policy to migration, has risen to 12 percent in the polls. Fiery Sahra Wagenknecht, the leading economic thinker in the generally pro-migrant Left party, warned lately that "taking in and integrating a large number of refugees and immigrants involves huge problems. It is harder than the 'Yes we can' slogans that Merkel tried to talk us into last fall." None of the forces arrayed against Merkel shows signs of making common cause with the others. She rules through a "grand coalition," in which former rivals the Christian Democrats and the Social Democrats now collude rather than compete. Her position is not necessarily worsening.

But Germany's is. Erdogan now believes Merkel needs him more than he needs her. At the time the refugee pact was signed a few months ago, Germany (again speaking in the name of Europe) agreed to consider liberalizing travel from Turkey so that its citizens could come to Europe without visas. Europeans assumed that, since this would involve Turkey's fulfilling 72 different conditions, it could be safely ignored. And if we were still in 1995, it could be. But power has shifted. Foreign minister Mevlüt Cavusoglu told the Frankfurter Allgemeine two weeks after the coup that Turkey expected action on visa-free travel by October or it would reconsider the refugee deal. He has also said that Europe has not paid out most of the $4 billion installment it promised to Turkey last spring, and he appears to be right. German politicians responded by harrumphing about the rule of law. "You can't just change the rules of the game arbitrarily," said the Bavarian conserv­ative politician Manfred Weber. Fellow Christian Social Union member Andreas Scheuer added, "We're not in a Turkish bazaar."

Well, that depends who you ask. European countries no longer necessarily call the tune in such confrontations. They are disarmed, shrinking, and irresolute. Now they are having trouble finding the resources even to steer the migration their policies set in motion.

Christopher Caldwell is a senior editor at The Weekly Standard.