BEFORE reading a “poem” on German television on March 31st, Jan Böhmermann, a satirist of questionable tact, explained that he wanted to clarify the boundaries of free-speech law. He then declaimed a series of obviously fictional passages (in rhyming verse) depicting Recep Tayyip Erdogan, the president of Turkey, engrossed in a series of athletically challenging sexual activities with barnyard animals. By the time the broadcaster took the video off its website a day later, it had caused a diplomatic fracas between Turkey and Germany.

The tension had been a long time brewing. In 2007 the chancellor, Angela Merkel, snubbed Mr Erdogan by opposing Turkish membership of the European Union. As Mr Erdogan’s rule became increasingly autocratic, Mrs Merkel often chided him for nobbling dissidents and the press. But in 2015 refugees started streaming into the EU via Turkey. Suddenly Mrs Merkel needed Mr Erdogan’s help.

The result is the deal that the EU, at Mrs Merkel’s prodding, made with Turkey last month. In return for taking back migrants from Greece and cracking down on people-smugglers, Turkey gets billions in aid and new talks about joining the EU. Its citizens will also be allowed to travel visa-free in Europe. Mrs Merkel is now reluctant to criticise Mr Erdogan.

Basking in its new importance, Turkey has summoned the German ambassador for a dressing-down three times in recent weeks. One complaint was over a mildly satirical song about Mr Erdogan aired on German television on March 17th. At that point Mrs Merkel declared press freedom sacrosanct—prompting Mr Böhmermann to up the ante.

On April 10th Ankara dispatched a formal diplomatic note, invoking an antiquated German law against insulting foreign heads of state. In theory Mr Böhmermann could go to prison for three years, if the German government decides to prosecute. Amid howls of outrage in Germany, Mrs Merkel has yet to rule this out. Mr Erdogan has also filed a personal complaint on the same charges.

Mrs Merkel will need all her diplomatic skill to contain this spat. The stakes are greater than Mr Erdogan’s fragile ego: freedom of speech, the refugee crisis and Syrian policy are all in the mix. Meanwhile, another blow-up is on the horizon. This spring the German Bundestag is set to vote on whether the mass killings of Armenians by Turks a century ago constituted genocide. Expect Turkish tempers to fray.