Germany will allow the potential prosecution of a top comedian after the Turkish president filed a complaint.
Jan Boehmermann had recited a satirical poem on television which made sexual references to Recep Tayyip Erdogan.
Under German law, Chancellor Angela Merkel's government had to approve a criminal inquiry.
Mrs Merkel stressed that the courts would have the final word, and it was now up to prosecutors to decide whether to press charges.
The chancellor added that her government would move to repeal the controversial and little-used Article 103 of the penal code, which concerns insults against foreign heads of state, by 2018.
Boehmermann is a satirist and television presenter well-known for pushing the boundaries of German humour. He was given police protection earlier this week.
Some experts say he has a strong defence against potential charges, because his poem could be seen as part of a wider piece of satire about free speech, rather than a deliberate insult, the BBC's Damien McGuinness reports from Berlin.
An earlier remark by Mrs Merkel that the poem was "deliberately offensive" had led to accusations in Germany that she was not standing up for free speech.
The poem was broadcast on ZDF television two weeks ago. The public TV channel has decided not to broadcast Boehmermann's weekly satire programme this week because of the furore surrounding him.
Paragraph 103 of Germany's penal code, on defamation of organs and representatives of foreign states, has the following to say:
(1) Whosoever insults a foreign head of state, or, with respect to his position, a member of a foreign government who is in Germany in his official capacity, or a head of a foreign diplomatic mission who is accredited in the Federal territory shall be liable to imprisonment not exceeding three years or a fine, in case of a slanderous insult to imprisonment from three months to five years.
The article dates back to the penal code drafted when the German Empire was formed in 1871, although at that time it just applied to monarchs.
It has been little used in recent years and is colloquially known as the "Shah law" among German lawyers after the Shah of Persia successfully brought a case against a Cologne newspaper in 1964.
A Swiss man living in Bavaria was also prosecuted under the article in 2007, after he posted offensive comments about the then-Swiss President, Micheline Calmy-Rey, on the internet, according to German and Swiss media.
Before announcing that Boehmermann could be prosecuted, Mrs Merkel stressed her government expected Turkey to comply with EU democratic norms in the areas of free speech and judicial independence.
"In a state under the rule of law, it is not a matter for the government but rather for state prosecutors and courts to weigh personal rights issues and other concerns affecting press and artistic freedom," she said.
"The presumption of innocence applies," she added, explaining that she was not making any prejudgement about Boehmermann.
In her statement in Berlin, Mrs Merkel said that the approval of the federal government was a legal precondition for the prosecution of this specific offence.
"The foreign office, the justice ministry, the interior ministry and the chancellery took part in this review," she said.
"There were diverging opinions between the coalition partners... The result is that in the present case the federal government will grant its approval."
Mr Erdogan has drawn much criticism in Turkey and internationally for attacking opponents, including harassment of journalists. Many accuse him of authoritarian methods, stifling legitimate dissent and promoting an Islamist agenda.
Some Germans worry that Mrs Merkel is compromising on freedom of expression in order to ensure Turkey's continued co-operation to stem the influx of migrants into the EU.
Thomas Oppermann, head of the Social Democrat (SPD) group in the German parliament, tweeted: "Prosecution of satire due to 'lese majesty' does not fit with modern democracy."