An Indonesian man working for an organisation that helped draft strict religious laws has been publicly whipped himself after he was caught having an affair with a married woman.

Flogging is a common punishment for a range of offences in the deeply conservative Aceh region on Sumatra island, including adultery, drinking alcohol, and having gay or premarital sex.

Aceh is the only region in the world’s biggest Muslim-majority nation that imposes Islamic law, part of a 2005 autonomy deal with the central government that ended a decades-long separatist insurgency.

On Thursday, a masked religious officer lashed Mukhlis, an Aceh Ulema Council (MPU) member, 28 times on the back after he was caught with a married woman last month.

Mukhlis, who like many Indonesians goes by one name, grimaced and flinched during the punishment in the provincial capital, Banda Aceh. The woman was then flogged with a rattan cane 23 times.

The organisation for which Mukhlis works advised the local government and legislature on drafting and implementing Aceh’s religious law, including public flogging.

It was not immediately clear what he did for the agency.

The council made headlines this summer when it criticised plans to form a national women’s football league because Aceh did not have a special stadium where only female players, match officials and spectators would be present.

In June, it issued a fatwa, or religious edict, against the online game PlayerUnknown’s Battlegrounds (PUBG), saying it insulted Islam and made addicted players violent.

Flogging a council member underlined the commitment to enforcing Islamic law, said the Aceh Besar deputy regent, Husaini Wahab.

“No matter who you are … if you violate [Islamic] law you will be whipped,” he told reporters after the punishment.

Mukhlis would probably be sacked under his employer’s moral code, Wahab added.

Also on Thursday, a female university student was flogged a dozen times after she was caught spending the night in a boarding house with a man, who escaped punishment because he was underage.

Dozens of onlookers watched the floggings, with some recording them on their mobile phones. “I was just curious to see how it was carried out,” said one spectator, Robbi.

In July, three people were each flogged 100 times for having premarital sex, while last year two men caught having sex with underaged girls were also whipped 100 times.

Rights groups have criticised public caning as a cruel and inhuman punishment, and Indonesia’s president, Joko Widodo, has called for it to end. But the practice has wide support among Aceh’s mostly Muslim population.