German Chancellor Angela Merkel vowed Friday to repeal the country’s law on insulting a head of state while simultaneously granting a Turkish request to allow the possible prosecution of a German TV comedian who wrote a crude poem about Turkey's president.

Ankara demanded last week to have comedian Jan Boehmermann prosecuted for insulting a foreign head of state. German law required Merkel's government to grant permission for prosecutors to press charges — if they choose to do so.

But Merkel now says the government intends to repeal the law.

While permission to prosecute was granted in this case, she said the government agreed that the law allowing prosecution for insulting a foreign head of state is "dispensable in the future."

Merkel stressed that it "means neither a prejudgment of the person affected nor a decision about the limits of freedom of art, the press and opinion." She underlined the independence of the judiciary and the presumption of innocence.

Boehmermann read the poem on ZDF television two weeks ago to illustrate what he said wouldn't be allowed in Germany, contrasting it with another channel's earlier satirical song that also poked fun at Turkish President Recep Tayyip Erdogan and angered Turkey.

ZDF withdrew the passage from its archives but argues that it didn't break the law.

The request posed an awkward choice for Germany at a time when Merkel is relying on Turkey to reduce the influx of migrants to Europe.

Officials spent days mulling Turkey's demand, and Merkel acknowledged that there had been internal divisions.

The Associated Press contributed to this report.