KUALA LUMPUR (REUTERS) - A Malaysian religious court sentenced five men on Thursday (Nov 7) to jail, caning and fines for attempting gay sex, media and a rights group said.

Sodomy and same-sex acts are illegal under Islamic law in Muslim-majority Malaysia, although convictions are rare.

The Selangor Syariah High Court, on the outskirts of the Malaysian capital, sentenced four men to six months' jail, six strokes of the cane, and a RM4,800 (S$1,577) fine for "attempting intercourse against the order of nature", the Malay-language daily Harian Metro reported.

A fifth man was sentenced to seven months' jail, six strokes of the cane and a RM4,900 fine for the same offence.

Islamic enforcement officers detained the five accused with seven other men during a November 2018 raid on a two-storey apartment, Harian Metro reported, citing judge Mohamad Asri Mohamad Tahir.

"The facts show that there was an attempt to carry out intercourse outside of the order of nature and that it was not in the early stages of preparation," Mr Mohamad Asri was quoted as saying.

Reuters could not reach the judge for comment and calls to the Selangor Syariah High Court went unanswered. A lawyer for the men did not respond to a request for comment.

Malaysia is home to 32 million people, where ethnic Malay Muslims make up more than 60 per cent of the population.

It has a dual-track legal system, with Islamic criminal and family laws applicable to Muslims running alongside civil laws.

Related Story Malaysia will not stop its guests based on sexual orientation: Tourism Ministry

Related Story Rising concern in Malaysia's LGBT community after attack on transgender woman

Mr Numan Afifi, president of sexuality rights' group Pelangi, said the sentencing was "outrageous" and could create an environment of fear within the LGBT community.

Mr Afifi, who attended the court hearing, said five other men arrested with the accused will also be sentenced on Nov 19.

The case comes amid concerns around growing intolerance towards the LGBT community in Malaysia in recent months.

In September 2018, two women were caned for "attempting lesbian sex" in the east coast state of Terengganu.

Earlier this year, a minister and other Muslim groups protested after LGBT activists attended a march for International Women's Day.