A court in Norway has sentenced Islamic cleric Mullah Krekar to five years in prison for posting death threats online against three Kurds and Norwegian officials.

Mullah Krekar, whose birth name is Najm Faraj Ahmad, warned that three Kurdish men would be killed under Islamic law because they insulted the Quran.

Two of them burned parts of the holy book during a 2010 protest. The third man published a book analyzing the Quran's references to women and sex. Krekar found both acts offensive to Islam.

Krekar's threats to the Norwegian officials, including former Foreign Minister Erna Solberg, came after a failed attempt to reverse a 2005 order to deport him to Iraq from Norway.

Oslo courts deemed the Islamic cleric a national security threat and ordered his deportation. However, the order was repeatedly postponed over fears that Krekar risked torture or even execution in Iraq.

Krekar commented to international media in June 2010 that Norway would pay a price for his death if he was deported.

If for example Erna Solberg deports me and I die as a result, she will suffer the same fate, Krekar said in Arabic. I don't know who will kill her: Al Qaeda, Ansar al-Islam, my family, my children. I don't know...But she will pay the price.

Krekar has admitted to making all the statements, but defended himself by claiming he was simply repeating Islamic principles.

He immediately appealed the 5-year prison sentence. His lawyer, Brynjar Meling, said he was surprised at the conviction.

Although Norway guarantees free speech, Krekar's threats were considered violent and could lead to danger for those targeted. Norway is likely also haunted by last year's massacre of 77 people by Anders Behring Breivik, who also posted his opinions on the Internet.

The judgment shows that the moment your speech creates danger, you can't claim freedom of speech. Threats are punishable,  prosecutor Marit Bakkevig told the Associated Press.

Krekar came to Norway in 1991 as a refugee.

He is the founder of Ansar al-Islam, a Sunni Islamist group of Iraqis with links to Al Qaeda. He claimed to have stepped down from his leadership position in 2002.

He has also been placed on the United States' and United Nations' list of persons affiliated with Al Qaeda, although he denies having any links.

With the rise of violent jihadist attacks, such as the Toulouse massacre in France, judicial decisions like the Krekar case will establish to what extent freedom of religion and speech apply.

The cleric's appeal will go to Norway's appeals court within two months and the case could be taken up for a new trial in the fall.