Indonesia’s top court the Constitutional Court ruled on Thursday against making gay sex and sex outside marriage illegal in a victory for the country’s besieged LGBTQI minority.

The 5-to-4 decision of the nine-judge panel of the Constitutional Court rejected the arguments of a conservative group, the Family Love Alliance, which was behind the case. Members of the group wept as it became clear the court would not side with them.

Rights advocates had feared the court would outlaw gay sex and sex outside marriage and set back human rights in the world’s most populous Muslim nation.

The ruling said it’s not the Constitutional Court’s role to criminalise private behaviour or to usurp parliament by imposing laws on it. The court’s decision is final.

Judge Saldi Irsa said the petitioners were in effect asking the court to formulate a new criminal code because they feared parliament would took take too long to enact changes wanted by the Family Love Alliance.

“The argument that the process of formulating legislation takes a long time could not be the justifying reason for the Constitutional Court to take over the authority of lawmakers,” he said.

In a dissenting opinion, four judges argued to outlaw same-sex relations and sex outside marriage on morality grounds.

In the past two years, LGBTQI Indonesians have endured a wave of hostility that has been stoked by inflammatory public statements from conservative officials and religious groups. Police have raided gay clubs and private parties, charging those arrested under Indonesia’s broad anti-pornography laws.

Aceh, a semi-autonomous province that practices sharia law, caned two young men for gay sex before a baying crowd of thousands in May after vigilantes broke into their home and handed them over to religious police.

Naila Rizqi Zakiah, a lawyer at the Community Legal Aid Institute in Jakarta who argued against criminalisation, said the case was an attempt to “regress” Indonesia’s human rights protections.

This article appeared in the South China Morning Post print edition as: Court rejects bid to criminalise gay sex