Sweden’s highest court has acquitted a Pentecostal pastor of hate crimes after he compared homosexuality to paedophilia and bestiality.

He was convicted in 2004 under Sweden’s hate crimes law but today, the country’s Supreme Court upheld an appeals court verdict that found that the comments made by Ake Green, 64, were protected by the country’s commitment to freedom of speech and religion.

Mr Green delivered a fiery anti-gay sermon two years ago that triggered a legal battle testing the limits of Sweden’s freedom of speech. Green told the Supreme Court that his sermon was meant to warn gays that their lifestyle will result in an “eternal divorce” from God.

“If two men sleep with each other, or if two women do so, it is abnormal, just like paedophilia,” Green said in his testimony.

Green became the first clergyman convicted under Sweden’s new hate crime legislation, which was modified in 2003 to include attacks against homosexuals. An appeals court overturned the ruling earlier this year, but Sweden’s chief prosecutor appealed the acquittal to the Supreme Court. The case has attracted widespread international attention, with some religious groups saying a conviction would be a threat to freedom of religion and speech. Others say an acquittal would open the door to fiercer attacks against Jews, Muslims and gays by right-wing extremists.

In 2003, Green told his congregation on the small island of Oland that homosexuality was “a deep cancerous tumours on all of society,” warning that Sweden risked a natural disaster because of leniency toward gays. He also said gays were more likely than others to rape children and animals.