Indonesia's constitutional court on Thursday narrowly rejected a petition by a conservative group to make extramarital sex illegal, but rights activists braced for a renewal of the battle in parliament and other state institutions.
Five of nine judges voted for the case to be thrown out, in a slim victory for rights activists who had feared the petition would spur moral policing and further discrimination against the gay community in the world's largest Muslim-majority country.
Most Indonesians adhere to a moderate form of Islam under an officially secular system, but there has been rise of a hardline, politicized Islam in recent years, which until recently had stayed on the fringe of the nation's politics.
Constitutional court chief justice Arief Hidayat said existing laws on adultery did not conflict with the constitution and it was not the court's authority to create new policies.
The judge said the question could be put to parliament, which is currently deliberating revisions to the national criminal code.
"The plaintiff should submit their petition to lawmakers, and there it should be an important input in the ongoing revision of the national criminal code," Hidayat said, as he read a summary of the 600-page ruling.
"Based on that view, the constitutional court is of the opinion that the petition is not legally sound."
Rights activists were comforted by the court's decision, while expecting more challenges to come.
"The decision is a relief because it shows it's possible to challenge the creeping conservatism in society," said Dede Oetomo, a prominent gay rights activist.
"But it's not over. There's parliament, there are other state institutions, they can turn to education, social organizations," he added.
The Family Love Alliance (AILA), a group of conservative academics and activists which put forward the petition, said it would not give up its fight.
"Aside from legal avenues, we can also go through government policy and programs so that sexual deviance is minimized and is an agenda for all of us," Euis Sunarti, a member of AILA, told reporters after the ruling.
AILA's petition had called for the definition of adultery to apply not just to married couples but to anyone in a marriage or outside it - effectively making all sex outside of marriage a crime.
In their complaint, AILA said certain articles in the national criminal code "threaten the resilience of families and therefore of Indonesia itself."
Some rights activists said the petition was partly aimed at criminalizing gay sex, which is currently not regulated by the law except in the ultra-conservative province of Aceh and in cases of child abuse.
Activists say such changes to the law would make it vulnerable to abuse, like the country's draconian anti-pornography laws, to target the LGBT community. Islamic parties pushed the anti-pornography laws in parliament soon after Indonesia ushered in its democratic era in 1998 and actively push an anti-LGBT agenda today.