The judge in the case of two male sex workers in Bahrain has said he gave them the maximum penalty as a deterrent to others, and a sign that “Homosexuality ruins individuals and nations.”

The men, Chinese migrant workers, had been employed in a massage parlour located above an institute for education in Islam, according to the Gulf Daily News.

After neighbours alerted police a sting operation was arranged, in which the two men offered to have sex with plainclothes police officers for 10 Bahraini dinar (£17.30).

In court the two pleaded guilty to prostitution and homosexuality. The judge, who remains unnamed, gave the maximum possible sentence of 5 years in jail, followed by deportation.

The judge said the sentence would be a deterrent to others, and added: “Homosexuality ruins individuals and nations.”

“For individuals, homosexuality causes bad behaviour, a lack of dignity, indecency, fear, pain, suicide and weakens people’s belief in Allah.

“For nations, it causes divine punishment, immorality, chaos, splits families and leads to less marriages and births.”

Although Bahrain’s laws do not prohibit adult, consensual sex between same-sex partners, since 2008 it has been reported that a government “crackdown” on homosexuality has aimed to rid the country of gay people.

Ministers called for the punishment of gay children and recommended that effeminate men be turned away at Bahrain’s airports.

 In 2011 a raid on a gay wedding party in Bahrain led to over 100 men being arrested.