BANDA ACEH, INDONESIA -- Two men in Indonesia's conservative Aceh province were publicly caned each 77 times Thursday after neighbours reported them to Islamic religious police for having sex.

Dozens of people witnessed the caning at Banda Aceh's Tamansari city park. It's the third time that Aceh, the only province in Indonesia to practice Shariah law, has caned people for homosexuality since the Islamic law was implemented in 2015 as a concession made by the government to end a long-running separatist rebellion.

The men, aged 27 and 29, were whipped across the back and winced with pain as a team of five enforcers wearing robes and hoods took turns, relieving one another after every 40 strokes.

The men were arrested in November after residents became suspicious and broke into their rented room where they were caught having sex, said Heru Triwijanarko, Aceh's acting Sharia police chief.

A Shariah court last month sentenced each man to 80 strokes, but they were caned 77 times after a remission for time spent in prison.

Four other people received 17 strokes for extra-marital relations and 40 strokes for drinking alcohol.

A Shariah code allows up to 100 lashes for morality offences including gay sex. Caning is also punishment for adultery, gambling, drinking and for women who wear tight clothes and men who skip Friday prayers.

With the exception of Aceh, homosexuality is not illegal in Indonesia, but the country's low-profile LGBT community has been under siege in the past years.