An Indonesian man who helped draft the country’s strict adultery laws – which includes public flogging – was caught having an affair with a married woman and fell victim to the laws he created.

Mukhlis bin Muhammad, 46, was apparently caught by officials in September having sex with an unnamed married woman in a car parked near a tourist beach, the BBC reported.

On Thursday, Mukhlis was caned 28 times in Aech, a semi-autonomous province on the northwest tip of Sumatra Island that still practices strict Sharia law.

BURMESE ACTORS GET 1-YEAR JAIL TERM FOR SATIRIZING MILITARY

The woman Mukhlis had the affair with was caned 23 times as she knelt on the floor covered by a white cloth.

“This is God’s law. Anyone must be flogged if proven guilty, even if he is a member of the MPU,” Husaini Wahab, the deputy mayor of Aceh Besar district, told the BBC.

The MPU – or Aceh Ulema Council – advises local governments and legislature on drafting and implementing Sharia law.

PAKISTAN TRAIN FIRE SPARKED BY GAS STOVE EXPLOSION KILLS DOZENS

Aceh is the only province in the world’s most populous Muslim-majority country that imposes Sharia law. It was adopted in 2001. Under the current legislature, suspects can be flogged for a range of offenses including gambling, drinking alcohol, gay sex, sex before marriage and extramarital affairs.

“This law is designated to have a deterrent effect, not only for the offenders but for the spectators who watch the caning,” Marwan, the head of the local public order agency, told reporters (via news.com.au). “The pain of being flogged is not that bad, the embarrassment is worse.”

CLICK HERE TO GET THE FOX NEWS APP

According to Husaini, Mukhlis is also an Islamic religious leader – making him the first to be publicly caned in Aceh since the law came into force.

He said Mukhlis will also be expelled from the MPU for his actions.