German chancellor Angela Merkel is in a tight spot after Turkey filed a complaint against a German satirist who read out an obscene poem about Turkish president Recep Tayyip Erdogan on TV.

The provocation by comedian Jan Boehmermann puts her in a dilemma of having to choose between protecting free speech or protecting the recently signed EU-Turkey deal that aims to stem the flow of migrants to Europe.

Student or retired? Then this plan is for you.

Boehmermann, the host of the late-night “Neo Magazin Royale” show on the ZDF public broadcaster, on 31 March recited a poem which said Erdogan represses Kurds and Christians and has sex with animals.

Prosecutors in Mainz said Erdogan had filed a legal complaint on Monday (11 April) against Boehmermann for insulting him.

If found guilty, he could be imprisoned for up to a year under Germany’s criminal code.

Erdogan's German lawyer, Michael-Hubertus von Sprenger, said he was prepared to go to the supreme court if need be. He added that the Turkish president personally wanted Boehmermann to be punished.

A second case could see Boehmermann spend three years in prison, Reuters reports.

Prosecutors are conducting a parallel investigation on suspicion of the more serious crime of “offending foreign states' organs and representatives”, also following a formal request by Turkey.

In the second case, the German government has to authorise prosecutors to go ahead. Berlin will decide in the coming days, Merkel said Tuesday.

She said she cherished artistic freedom in Germany.

“Art and these fundamental values are valid regardless of any political problems we are discussing with each other, and that includes the refugee issue,” Merkel said on Tuesday.

But she also praised Turkey, which has promised to take back irregular migrants from Greece.

“Turkey is bearing a very big burden in relation to the Syrian civil war but all of that is completely separate from Germany's fundamental values ... freedom of the press, opinion and science apply and are completely separate from that,” she said.

Merkel earlier told Turkey’s prime minister, Ahmet Davutoglu, that the poem was a “deliberately offensive text” that she personally disapproved of.

But that did not discourage Ankara from requesting the prosecution.

Boehmermann is now under police protection, according to German media, for fear of attacks by pro-Erdogan supporters in Germany. He has also cancelled the next episode of Neo Magazin Royale.

The situation in Germany recalls Erdogan’s crackdown on free speech inside Turkey.

He recently seized the leading opposition newspaper - Zaman.

He has jailed dozens of government-criticial journalists using anti-terrorism laws. He has indicted more than 1,800 people for “insulting” his office, some of them for merely “liking” other people’s social media posts.

The German comedian is used to controversy.

In March 2015, Boehmermann claimed that he had a video clip in which Greece’s then finance minister Yannis Varoufakis showed the middle finger to the German people. He later admitted it was a hoax.

Varoufakis on Tuesday expressed solidarity with Boehmermann.

“Europe first lost its soul (agreement with Turkey on refugees), now it is losing its humour. Hands off @janboehm!,” he said on Twitter, using Boehmermann’s Twitter handle.

Guy Verhofstadt, the leader of the liberals in the European Parliament, said that in a free world even bad taste is allowed.

“It worries me that we are now at the mercy of an authoritarian leader like Erdogan who wants to show that he can curtail our freedoms, just like he does in his own country,” he said in a statement.