If found guilty, two men from the Indonesian province of Aceh who were discovered having sex together will be the first to be caned for gay sex under a new code implemented two years ago, Marzuki, the Shariah police's chief investigator, said on Saturday.

"Based on our investigation, testimony of witnesses and evidence, we can prove that they violated Islamic Shariah law and we can take them to court," said Marzuki, who goes by a single name.

The new code allows up to 100 lashes for morality offenses including gay sex, adultery, gambling, drinking alcohol, the wearing of tight clothes by women and skipping Friday prayers in the case of men.

Homosexuality is not illegal in Indonesia, but a judicial review being considered by the Constitutional Court is seeking to criminalize sex outside marriage and sex between people of the same gender.

Read:The invisible scars left by strikes of the cane

Civilian vigilantism

Residents caught the men having sex on March 28 in a rented room in the provincial capital Banda Aceh, an official at the provincial public order department told the German press agency DPA.

The men - aged 23 and 20 - were reported to the police on March 29, Marzuki said. He added that the men had "confessed" to "being a gay couple." This was supported, he said, by video footage taken by a resident showing one of the men naked and distressed as he calls for help on his cellphone. The second man is repeatedly pushed by another man who is preventing the couple from leaving the room.

Under the code, sex out of wedlock is punishable by up to 100 strokes of the cane. An earlier version of the code did not regulate punishment for gay sex.

Jakarta signed a peace agreement with Aceh separatist rebels in 2005, ending decades of conflict that killed more than 15,000 people.

jbh/tj (AP, dpa)