(CNN) An Indonesian man has been publicly flogged for adultery, under a draconian law he helped create.

Mukhlis, a member of the Aceh Ulema Council (MPU) in the deeply conservative Aceh province of Indonesia, received 28 lashes in front of a crowd on Thursday after being caught having an affair with a married woman. Like many Indonesians, Mukhlis goes by a single name.

His agency advises the local government on drafting and implementing religious laws.

A video by the AFP news agency shows him grimacing as each strike is delivered onto his back by a masked officer on a stage, in front of a handful of onlookers -- some of whom filmed on their cell phones. The woman with whom he was caught also received a series of lashes.

Aceh, the country's only region to impose Sharia law, uses caning to punish a series of offenses, such as homosexuality, drinking alcohol and having sex outside of marriage.

"We have clarified his identity and we proceeded with the investigation and handed over the dossier to prosecutors, and today we carried out the implementation of the flogging punishment," AFP reported Muhammad Hidayat, the Banda Aceh sharia police chief, as telling reporters at the caning.

"A lot of things we can learn, but ultimately we have to enforce God's laws, especially on Islamic land like here," Muhammad Ramdan, a Banda Aceh resident, added.

The state's Sharia criminal code went into effect in September 2015, and a number of people have been caned under the laws.

Last year 15 people, including five women, received the punishment for a variety of crimes. Before that, two men were lashed 83 times for homosexuality.

"No matter who you are... if you violate (Islamic) law you will be whipped," Husaini Wahab, the deputy regent of the Aceh Besar municipality, told AFP after the latest caning.