JAKARTA, Indonesia — Sweeping legislation that would have criminalized sex between unmarried people, including gays and lesbians, was pushed back on Friday by Indonesia’s president, Joko Widodo, days before it had been expected to pass.
The measure, aimed at overhauling Indonesia’s penal code, had appeared likely to win approval next Tuesday from the country’s outgoing Parliament, with Mr. Joko’s blessing.
But after an outpouring of opposition to many of its provisions from rights activists, women’s groups, legal experts and other Indonesians, Mr. Joko announced that he had asked lawmakers to drop the legislation and leave the matter for the next Parliament, which will be seated in October.
“After examining input from various groups who objected to some of the substance of the criminal bill draft, I concluded that there were still materials that needed further study,” Mr. Joko told reporters at the presidential palace in Bogor, south of Jakarta.
For Islamists in Indonesia, which has the world’s largest Muslim-majority population and an officially secular government, passing the bill would have been a major victory. Some had said that if Mr. Joko secured its passage, his name “would be written in history with golden ink.”
Many of the wide-ranging bill’s provisions — it had 628 articles — mirrored elements of Shariah, the Islamic legal code. It would have restricted access to contraception for minors, outlawed cohabitation without marriage, restricted freedom of speech, reduced the rights of religious minorities and imposed harsh punishment for insulting the dignity of the president.
A provision punishing sex outside marriage with up to a year in prison would have effectively banned gay and lesbian relations, although the bill did not spell that out. Indonesia does not allow same-sex marriages.
Indonesian Muslims are known as being relatively moderate, but intolerance has been on the rise for the last two decades. Around the sprawling archipelago, local governments have enacted more than 600 measures adopting aspects of Shariah, including requiring women to wear hijabs and imposing curfews on them unless they are accompanied by a male relative.
While the president has pulled the plug on the national legislation for now, similar measures are certain to be introduced after the new Parliament is sworn in.
“This is the slow-moving Islamization of Indonesia,” said Andreas Harsono, senior Indonesia researcher at Human Rights Watch. “For the Islamists, this is the crown jewel of their advocacy.”
The legislation would have taken effect in two years, once regulations had been drafted to implement it.
Opponents of the bill were particularly concerned about provisions that targeted reproductive rights, including restrictions on abortion and on providing contraception to anyone under 18.
The ban on consensual sex between unmarried adults would have applied to foreigners as well as Indonesians, and it would have been likely to discourage some Westerners from visiting at a time when the country is trying to attract more tourists.
And foreign investors, also much desired by the government, are likely to take such far-reaching legislation into account when deciding where to put their money. Some international companies, especially those with diversity policies protecting their workers, were concerned about how the bill would affect their employees in Indonesia who are gay or in nonmarital relationships.
“A change in the criminal justice law would obviously have a potential impact on the investment climate,” said A. Lin Neumann, managing director of the American Chamber of Commerce in Indonesia, which represents nearly 300 American companies operating in the country.
Mr. Harsono of Human Rights Watch said the bill would also have restricted the rights of nonsanctioned religious groups and government critics.
It would have strengthened Indonesia’s law against blasphemy, which protects the country’s six officially recognized religions — Islam, Protestantism, Catholicism, Hinduism, Buddhism and Confucianism — but is most often invoked by Muslims.
The legislation also would have expanded the country’s laws against treason, which is punishable by death, to include actions that could be considered political speech, he said.
Other articles would have prohibited insulting the president, the vice president, the government or state agencies.
Many of the proposals in the legislation have been discussed for years but had never made much headway in previous Parliaments.
But after April’s presidential election, in which Mr. Joko easily won a second five-year term, the move to adopt the legislation gained steam.
Mr. Joko’s vice-presidential running mate was Ma’ruf Amin, the 76-year-old head of the Indonesian Ulema Council, an influential body of Muslim leaders. In a letter to the president last month, the council urged Mr. Joko to approve the bill. The letter was signed by Mr. Ma’ruf, who will be sworn in as vice president next month.
Until Friday, the president seemed to be backing the legislation, which had advanced in Parliament with his apparent approval.
One lawmaker who supported the bill, Arsul Sani of the United Development Party, one of four Islamist parties in Parliament, said the legislation reflected a turn against Western ways of thinking.
“Indonesia has social values, moral values, also cultural values that are different from those in Western countries,” said Mr. Arsul, who studied in Australia and Scotland.
But critics of the bill said it would have given the government too much power over people’s personal lives — and village chiefs too much authority to enforce the morality laws.
“Criminal law must not enter private life,” said Maidina Rahmawati, a researcher at the Institute for Criminal and Justice Reform, an independent research center.