BERLIN — German prosecutors on Tuesday dropped an investigation of a TV comic who wrote a crude poem about Turkish President Recep Tayyip Erdogan, citing insufficient evidence that he committed any crime.

Chancellor Angela Merkel in April granted a Turkish request to allow the possible prosecution of Jan Boehmermann for insulting a foreign head of state. German law required the government to grant permission before prosecutors could consider whether to press charges.

Boehmermann had read the poem on ZDF television, to illustrate something he said wouldn’t be allowed in Germany. He contrasted it with another channel’s earlier satirical song that also poked fun at Erdogan and angered Turkey but was considered acceptable in Germany.

Boehmermann’s ditty started by describing the Turkish leader as “stupid, cowardly and uptight” before descending into crude sexual references. ZDF withdrew the passage with the poem from its archives but argued that it didn’t break the law.

Prosecutors in Mainz, where ZDF is based, said in a statement Tuesday that “criminal actions could not be proven with the necessary certainty.”

They said it was “questionable” whether the poem constituted slander, given the satirical context in which Boehmermann recited it and the fact that it wasn’t intended to convey his own view of “personal traits of the Turkish president.”

Boehmermann, it said, maintained that he had sought to exaggerate to the extent that “the lack of earnestness and the lack of any seriously intended connection to the personal honor of (Erdogan) were supposed to be immediately evident to every listener.”

Prosecutors said they also found no evidence of criminal behavior on the part of other people involved in Boehmermann’s program.

The decision to allow Boehmermann’s possible prosecution was awkward for Merkel as she sought Ankara’s help in reducing Europe’s migrant influx but also expressed concern about the state of media freedom in Turkey.

As she announced the decision in April, she underlined the independence of the judiciary and said her government intends to repeal Germany’s law criminalizing insults of a foreign head of state, effective in 2018.

In a separate civil case at a Hamburg court, a Hamburg court in May granted an injunction ordering Boehmermann not to repeat most of the offending poem. A full hearing on that case is due in November.