Aceh's regional parliament adopted the bill despite strong objections from human rights groups and the province's deputy governor, who said the legislation needed more careful consideration because it imposes a new form of capital punishment.
The chairman of the 69-seat house asked if the bill could be passed into law and members answered in unison: "Yes, it can." Some members of the moderate Democrat Party had voiced reservations, but none of them voted against the bill.
The law, which reinforces the province's already strict Islamic laws, is to go into effect within 30 days. Its passage comes two weeks before a new assembly led by the moderate Aceh Party will be sworn in following a heavy defeat of conservative Muslim parties in local elections.
Aceh, where Islam first arrived in Indonesia from Saudi Arabia centuries ago, enjoys semiautonomy from the central government.
A long-running Islamic insurgency in the province ended in 2005 in the wake of the Indian Ocean tsunami that killed 130,000 there.
A version of Islamic law, or Shariah, that had been introduced in Aceh in 2001 already bans gambling and drinking alcohol, and makes it compulsory for women to wear headscarves. Dozens of public canings have been carried out by the local Shariah police against violators of that law.