Tourists visiting Indonesia will not be prosecuted under a new law criminalizing sex outside marriage, the BBC reports.

The new law, dubbed the "Balinese ban on sex," threatens imprisonment for up to a year for unmarried couples or up to six months for those who cohabit.

But Bali's governor said authorities will not check the marital status of tourists.

The law is due to take effect in three years, but could run into legal problems.

The new law is part of a slew of changes to the penal code that have been introduced following the rise of religious conservatism in the Muslim-majority country.

Although the ban on extramarital sex has attracted the most attention abroad, many in Indonesia fear that other parts of the new code will be more damaging, such as if criticizing the president or vice president becomes a crime.

The UN says the new laws could undermine human rights in the country, but Indonesian officials say the legislation will uphold Indonesian values.

Companies are concerned that these changes will hit Indonesia's tourism industry, making the country less attractive while it is still trying to recover from the devastating Covid pandemic.

More than 16 million people visited Indonesia in 2019.

Although the law would technically apply to locals and foreigners, officials have tried to allay fears about prosecuting tourists.

Indonesia's deputy justice minister promised that foreigners would not be prosecuted. The government also points out that under the new criminal code, extramarital sex and cohabitation offenses will only be prosecuted if reported by a spouse, parent or child.