The new code bans both premarital and extramarital sexual relations, with a punishment of up to one year in prison.
Indonesia's parliament approved a new criminal code on Tuesday, banning sex outside marriage with a punishment of up to one year in prison.
While the country already bans adultery, the new law -- which passed with support from all political parties -- would also include premarital sex. It would apply to Indonesians and foreigners alike, and prohibit cohabitation between unmarried couples.
The new laws won't come into effect for three years to allow for implementing regulations to be drafted.
The national response to the law has been mixed, with some protests in the capital, Jakarta, on Tuesday.
Legislators defended the passage of the criminal code -- which was decades in the making -- as much-needed overhaul of colonial laws.
"The old code belongs to Dutch heritage ... and is no longer relevant now," said Bambang Wuryanto, head of the parliamentary commission in charge of revising the code.
However, several newspapers and critics of the law have decried it as part of an erosion of civil liberties in what is the world's third-largest democracy. Other laws ban black magic, insulting the president or state institutions, spreading views against state ideology, and staging protests without notification.
Daily newspaper Koran Tempo claimed the code had "authoritarian" tones, while the Jakarta Post expressed "grave concerns”.
Indonesia’s tourist sector has also expressed reservations about the new code, worrying that the ban may scare away tourists from its tropical shores — especially as Indonesia recovers from the impacts of COVID-19 and tries to attract more so-called “digital nomads” by offering a more flexible visa.
"We deeply regret the government have closed their eyes. We have already expressed our concern to the ministry of tourism about how harmful this law is," said Maulana Yusran, deputy chief of Indonesia's tourism industry board.
The ban on extramarital sex was partially watered down from an earlier version of the bill so that individuals can only reported by limited parties, such as a close relative or spouse. Albert Aries, a spokesperson for Indonesia's justice ministry, claimed that this would both “protect the institution of marriage and Indonesian values” as well as the “privacy of the community”.
The government had planned to pass a revision of the country's colonial-era criminal code in 2019, but was halted by nationwide protests. Lawmakers have since softened some of the provisions with President Joko Widodo urging parliament to pass the bill this year, ahead of the presidential elections scheduled for early 2024.