Indonesia is poised to pass a new penal code that criminalises consensual sex outside marriage and introduces stiff penalties for insulting the president's dignity - a move rights groups criticised as an intrusive assault on basic freedoms.

The world's most populous Muslim majority country has substantial Christian, Hindu and Buddhist minorities, but has seen a recent trend towards deeper religious piety and conservative Islamic activism.

The new criminal code is due to be adopted in the next week after parliament and the government agreed a final draft, four parliamentarians told the Reuters news agency.

The new penal code, would replace a Dutch colonial-era set of laws, was a long overdue expression of Indonesian independence and religiosity, they said.

"The state must protect citizens from behaviour that is contrary to the supreme precepts of God," said Nasir Djamil, a politician from the Prosperous Justice Party.

Delivering ballot boxes to Indonesia's hard to reach places Show all 10 1 /10 Delivering ballot boxes to Indonesia's hard to reach places Delivering ballot boxes to Indonesia's hard to reach places Workers transport ballot boxes to Bonto Matinggi village, South Sulawesi AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Army and police guards guide the delivery of ballot boxes in remote East Java AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Election officials deliver ballot boxes to a remote village in Southern Aceh AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes to Bandung in West Java amidst heavy flooding AP Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes to villages outside the city of Bogor EPA Delivering ballot boxes to Indonesia's hard to reach places Election officials load ballot boxes for delivery to a remote village in Southern Aceh AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes to remote villages in Papua province AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes by boat to remote villages in Papua province AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers load ballot boxes onto a lorry in North Sumatra AP Delivering ballot boxes to Indonesia's hard to reach places Army and police guards guide the delivery of ballot boxes in remote East Java Reuters

He said leaders of all religions had been consulted on the changes given that Indonesia's founding ideology was based on belief in God.

Under the proposed laws, unmarried couples who "live together as a husband and wife" could be jailed for six months or face a maximum fine of 10 million rupiah (£570), which is three months' salary for many Indonesians.

A prosecution can proceed if a village chief, who heads the lowest tier of government, files a complaint with police, and parents or children of the accused do not object.

Parents, children and spouses can also lodge a complaint.

The inclusion of the new power for village chiefs was warranted because "the victim of adultery is also society", another lawmaker, Teuku Taufiqulhadi, said.

The Institute for Criminal Justice Reform, an NGO, said millions of Indonesians could be ensnared by the new laws.

"Across the board, this is a ratcheting up of conservatism. It's extremely regressive," said Tim Lindsey, director of the University of Melbourne's Centre for Indonesian Law, Islam and Society.

A maximum one-year prison term also can be applied to a person who has sex with someone who is not their spouse and a close family member lodges a complaint.

The law also impacts homosexuals as gay marriage is not recognised in Indonesia.

The code also establishes prison terms for those found to commit "obscene acts", defined as violating norms of decency and politeness through "lust or sexuality", whether by heterosexuals or gay people.

The new laws will also apply to foreigners. However, asked whether tourists in Indonesia could face jail for extramarital sex, Mr Taufiqulhadi said: "No problem, as long as people don't know."

There would also be a maximum four-year prison term for women who have an abortion, applicable if there was no medical emergency or rape involved.

The code further introduces fines for some people who promote contraception, and a six-month prison term for unauthorised discussion of "tools of abortion".

Support free-thinking journalism and attend Independent events

In addition, local authorities would get greater freedom to introduce punishments for breaches of customary laws not covered in the penal code.

There are more than 400 local regulations that activists say impinge civil rights, such as the mandatory wearing of a hijab, an Islamic headscarf for women.

Meanwhile, parliament has reintroduced the offence of "attacking the honour or dignity" of Indonesia's president and vice president.

A similar law was struck down by the Constitutional Court in 2006, and the new version is likely to be challenged by rights activists as well.

Insulting the government and state institutions also carries a prison term.