Indonesia's new criminal code has grabbed headlines for making sex outside marriage illegal, but Islamic parties wanted even harsher punishment for moral crimes in the world's largest Muslim-majority nation, accounts of behind-the-scenes negotiations reveal.

The so-called morality code is just one part of the legislative overhaul ratified by the Indonesian parliament this month, a 226-page set of new laws critics say threaten civil liberties, but that officials defend as reflective of Indonesia's identity.

Behind the scenes, secular nationalist parties holding a majority in parliament opposed the tighter laws on morality but risked being branded supportive of sex outside marriage if they remained unyielding in their opposition.