(CNN) When Indonesia passed controversial amendments to its criminal code earlier this month, one aspect above all others dominated the headlines: the criminalization of sex outside marriage.
Tourism figures warned it would put foreigners off visiting and hurt Indonesia's global reputation -- no small matters in a country that welcomed up to 15 million international travelers annually before the pandemic and recently held the G20 presidency for the first time in its history.
Officials have since played down the likelihood of tourists being charged, but hundreds of millions of Indonesians still face the prospect of up to a year in jail for the same offense -- and rights activists warn that this is only the start of the new code's potential to threaten Indonesians' personal freedoms and civil liberties. Indonesian officials, on the other hand, defend the move as a necessary compromise in a democracy that is home to the world's largest Muslim population.
The new code also criminalizes cohabitation between unmarried couples and promoting contraception to minors, and enshrines laws against abortion (except in cases of rape and medical emergencies when the fetus is less than 12 weeks) and blasphemy.
It also limits Indonesians' right to protest and criminalizes insulting the president, members of his cabinet or the state ideology.
Offenders face the prospect of prison terms ranging from months to years.
Rights groups have been scathing in their assessments.
"In one fell swoop, Indonesia's human rights situation has taken a drastic turn for the worse," said Andreas Harsono, senior Indonesia researcher at Human Rights Watch.
"Potentially, millions of people will be subject to criminal prosecution under this deeply flawed law. Its passage is the beginning of an unmitigated disaster for human rights in Indonesia."
The creation of the new code is in part a reflection of the growing influence conservative Islam plays in the politics of what is the world's third-largest democracy.
About 230 million of the 270 million people who call this vast and diverse archipelago nation home are Muslim, though there are also sizable Christian and Hindu minorities and the country prides itself on a state ideology known as "Pancasila," which stresses inclusivity.
The constitution guarantees a secular government and freedom of religion, and criminal law is largely based on a secular code inherited from the former Dutch colonial power -- though the province of Aceh adopts and implements sharia law -- and Islamic principles influence some civil matters and local level by-laws.
However, more conservative forms of Islam that were once repressed under the former dictator Suharto have in recent years emerged as increasingly powerful forces at the ballot box.
In the most recent general election, in 2019, President Joko Widodo controversially picked an elderly Islamic cleric -- Ma'ruf Amin -- as his running mate in a move that was widely seen as a move to secure more Muslim votes.
The appointment of Ma'ruf raised eyebrows among Widodo's more moderate supporters, but it helped see off the challenge from the former military general Prabowo Subianto who had forged an alliance with hardline Islamist groups. Some of those groups had already demonstrated their clout by leading mass protests that led to the toppling of the Jakarta governor, Basuki Tjahaja Purnama, on a blasphemy charge.
The new criminal code -- which updates the code inherited from the Dutch and was passed unanimously by lawmakers belonging to multiple parties -- also reflects this growing influence of conservative Islam. Some conservative parties had been calling for an even stricter code, but previous proposals sparked mass street protests and were shelved after Widodo intervened.
Describing the new code as a "compromise", Indonesian officials have said it needed to reflect a spread of interests in a multicultural and multi-ethnic country.
Still, while the new code clearly has the backing of many conservative voters, critics paint it as a step backwards for civil liberties in what is still a fledgling democracy.
Indonesia spent decades under strong-man rule after declaring its independence from the Dutch in the 1940s, under its first president Sukarno and later under the military dictator Suharto. It was not until after Suharto's downfall in 1998 that it entered a period of reformation in which civilian rule, freedom of speech and a more liberal political environment were embraced.
Rights groups fear the new code risks undoing some of that progress by pandering to the conservative religious vote at the expense of the country's secular ideals and reinforcing discrimination against women and the LGBTQ community. They also fear its longer-term effects could be corrosive to the democratic system itself and see uncomfortable parallels to the country's authoritarian past.
Aspects of the code relating to insulting the president or the state ideology could, they say, be abused by officials to extort bribes, harass political opponents and even jail journalists and anyone deemed critical of the government.
"It is never a good thing when a state tries to legislate morality," said Zachary Abuza, a professor specializing in Southeast Asian politics and security issues at the National War College in Washington, DC. "The new code puts civil liberties at risk and gives the state powerful tools to punish ideological, moral and political offenses."
One political blogger, who asked not to be identified for fear of persecution under the new laws, told CNN that he expected online surveillance and censorship by the authorities to increase.
"The terms are not clear -- that's what makes the code especially scary and dangerous," he said. "It's all left to interpretation by the government."
He gave the example of someone liking a critical tweet about the president, asking if that would be enough to land the person in jail.
"It will boil down to whoever the government wants to prosecute," the blogger said.
It will be at least three years until the revised code comes into effect, according to officials, so it is still early to predict how the new laws will be implemented and enforced.
Much may depend on how satisfied more conservative voters are with the "compromise" code -- or how angry those who protested on the streets against its earlier formulation remain.
At the same time, there are those who question whether lawmakers have made the mistake of listening only to the loudest voices in an attempt to pick up votes.
Norshahril Saat, a senior fellow at the ISEAS-Yusof Ishak Institute, said there was a "complex relationship between Islam, politics, and society in Indonesia."
He pointed to a 2022 national survey commissioned by the institute that found most respondents considered themselves moderate and supported the idea of a secular state -- even though more than half of them also felt it was important to elect a Muslim leader.
Norshahril cautioned against concluding that support for the new criminal code was evidence of "a conservative Islamic tide."
"It may mean that the current slate of elected politicians are conservative but more likely that they are responding to pressure from some powerful conservative lobby groups," he said.
Of more concern, he said, is that "in today's Indonesia, all of the political parties unanimously agreed on criminalizing these 'sins'."