AN INDONESIAN man collapsed while being publicly caned Monday for having sex outside of marriage.

Herizal bin Yunus, 27, fainted after being caned eight times in front of a crowd in Aceh, the only province of the world’s most populous Muslim-majority country that imposes sharia law.

Officials carried him off stage after he collapsed during the punishment outside a mosque in the provincial capital Banda Aceh, which was carried out by a religious official dressed in an all-encompassing, hooded cloak.

But once he came to, a doctor examined him and said he was in good health, and he was taken back up on stage to be flogged another 14 times. A local religious court had sentenced him to be caned a total of 22 times.

The man had broken Islamic laws that forbid people in Aceh from spending time in close proximity with members of the opposite sex who are not their husband or wife.

He was one of eight people publicly caned on Monday for breaking the province’s Islamic regulations.

Public canings take place regularly in Aceh, and people can be punished for offences ranging from gambling, to drinking alcohol, to gay sex. However it is rare for someone to collapse.

Aceh, on the island of Sumatra, began implementing sharia law after being granted special autonomy in 2001, an attempt by the central government in Jakarta to quell a long-running separatist insurgency.

Islamic laws have been strengthened since the province struck a peace deal with Jakarta in 2005.