German prosecutors have to decide whether a TV comedian's poem about the Turkish president was mere satire, or a punishable offense.

German public broadcaster ZDF said Wednesday that prosecutors in the western city of Mainz have opened a preliminary probe into whether the poem broke the law.

If convicted of insulting a foreign head of state, Comedian Jan Boehmermann could face up to three years in prison.

Boehmermann read the poem in a program aired by ZDF television Thursday as an example of something that wouldn't be allowed in Germany, contrasting it with another channel's satirical song that also poked fun at Turkish President Recep Tayyip Erdogan.

While the German government defended the song as legitimate free speech, it has strongly distanced itself from the poem.