But what seemed like a policy breakthrough became a political albatross. Had Ms. Merkel refused to prosecute Mr. Böhmermann, Turkey could have pulled out of the deal. She has opted for the second, bad option, sullying her own liberal virtues.

Mr. Böhmermann got what he wanted; the clown has shown the powerful just how powerless they can be. But the affair also highlights the flaws of the Turkey deal itself.

First, there’s the calculation that bowing to the interests of the Turkish government was a fair price for tamping down the far right. But national support for the right-wing Alternative for Germany party remains strong, despite decreasing numbers of refugees. Ms. Merkel has won some respite from critics within her own party, but the deal has opened a new front, with the center left attacking her for acquiescing to Mr. Erdogan’s demands.

Nor does it work as policy. There are still hundreds of thousands of refugees in Europe and many more on the way, and still there is no agreement on how to share the burden across the Continent. Meanwhile, human traffickers are beginning to build new routes over Libya to Italy.

But what the Böhmermann affair shows most impressively is that the deal was struck for the wrong reasons at the wrong time. It was a panic reaction. Ms. Merkel was under immense political pressure; her party, the Christian Democrats, had just suffered setbacks in three state elections. Other European leaders are facing similar problems.

Europe came to the table quarreling and desperate — not as a partner, but as a beggar. Now Mr. Erdogan continues to treat Europe as such. Political realists love to cite game theory to justify their decisions; had they cracked open their textbooks for a refresher, they could have easily predicted this outcome.

Of course, the alternative cannot be to ignore Turkey; the refugee crisis has moved the world’s conflicts to our doorsteps. Germany — and Europe — need Turkey. And Germany and Europe will probably have to strike more than one deal with Turkey in the future, and will have to cooperate with autocratic states on many other issues. Even the center-right Christian Democrats, who have mostly blocked Turkey’s path to the European Union, even when Mr. Erdogan was still on a fairly liberal course, are finally recognizing this reality, which is for the good.

But the moral of this story about being less moralistic is this: If you are divided and weak, it doesn’t make sense to put on a strongman act in foreign policy. Let’s hope that next time the clown not only humbles the mighty, but also enlightens them.