Hamburg (AFP) - A court in the German city of Hamburg on Tuesday banned the author of a poem lampooning Turkish President Recep Tayyip Erdogan from publicly reciting passages from his work.

The court ruled that only six lines of the 24-line poem by German comedian Jan Boehmermann could be recited, offering the Turkish leader a partial legal victory.

The poem accused Erdogan of bestiality and paedophilia and has caused a storm in Germany over freedom of speech.

Chancellor Angela Merkel has come in for criticism after she authorised possible criminal proceedings against Boehmermann.

Any prosecution of the comedian would be launched under the rarely enforced section 103 of Germany's criminal code -- insulting organs or representatives of foreign states -- which carries up to three years in prison

Last week, the affair gathered still more publicity after a lawmaker from Merkel's Christian Democrat party recited the offending parts of the poem in parliament in a bid to condemn its content as an attack on Erdogan's "honour".

Boehmermann's own recital of his so-called "Defamatory Poem" on national television in March sparked a diplomatic firestorm after he admitted the work flouted Germany's legal limits to free speech and was intended as a provocation.

Merkel then authorised criminal proceedings against the comedian after Turkey requested he be prosecuted under the lese majeste law, a move which saw some of the chancellor's critics accuse her of kowtowing to Erdogan.

Boehmermann responded to Merkel's move by saying the German leader had "filleted me, served me up to a neurotic despot for tea and turned me into a German Ai Weiwei," in reference to the Chinese dissident artist.

In Tuesday's ruling the court found that "Erdogan does not have to put up with the expression of certain passages in view of their outrageous content attacking (his) honour."

The court found that such material overstepped the boundaries of decency in attacking the Turkish leader.

Boehmermann has indicated his poem was a response to Ankara's decision to summon Germany's ambassador to protest a satirical song broadcast on German TV which lampooned Erdogan in far tamer language.

The issue has soured relations between Berlin and Ankara even as Germany and Turkey seek to cooperate on the migrant crisis.