BERLIN — A German court has dismissed a television comedian's appeal of a ruling that prohibits him from repeating elements of a crude poem he wrote about Turkish President Recep Tayyip Erdogan.

Comic Jan Boehmermann recited the poem last year on public television to illustrate something he said wouldn't be allowed even in democratic Germany. The poem described Erdogan as "stupid, cowardly and uptight" before descending into sexual references.

Chancellor Angela Merkel granted a Turkish request to allow possible prosecution for insulting a foreign head of state. A Hamburg court issued an injunction ordering Boehmermann not to repeat most of the poem.

On Tuesday, an appeals court upheld that decision, rejecting both Boehmermann's appeal and a bid by Erdogan's lawyers to have the ban extended to the whole poem.

Both sides are entitled to seek a federal court appeal.