Shariah law official whips one of two men convicted of gay sex during a public caning outside a mosque in Banda Aceh, Aceh province Indonesia, Tuesday, May 23, 2017. Two men in the province were publicly caned dozens of times Tuesday for consensual sex, a punishment that intensifies an anti-gay backlash and which rights advocates denounced as "medieval torture." (AP Photo/Heri Juanda)

Shariah law official whips one of two men convicted of gay sex during a public caning outside a mosque in Banda Aceh, Aceh province Indonesia, Tuesday, May 23, 2017. Two men in the province were publicly caned dozens of times Tuesday for consensual sex, a punishment that intensifies an anti-gay backlash and which rights advocates denounced as "medieval torture." (AP Photo/Heri Juanda)

BANDA ACEH, Indonesia (AP) — Two men in Indonesia’s Aceh province were publicly caned dozens of times Tuesday for consensual gay sex, a punishment that intensifies an anti-gay backlash in the world’s most populous Muslim country and which rights advocates denounced as “medieval torture.”

More than a thousand people packed the courtyard of a mosque to witness the caning, which was the first time that Aceh, the only province in Indonesia to practice Shariah law, has caned people for homosexuality.

ADVERTISEMENT

The crowd shouted insults and cheered as the men, aged 20 and 23, were whipped across the back and winced with pain. Many in the crush of spectators filmed the caning with cellphones as a team of five robed and hooded enforcers took turns inflicting the punishment, relieving one another after every 20 strokes for one of the men and 40 for the other.

Sarojini Mutia Irfan, a female university student who witnessed the caning, said it was a necessary deterrent.

“What they have done is like a virus that can harm people’s morale,” she said. “This kind of public punishment is an attempt to stop the spread of the virus to other communities in Aceh.”

The couple were arrested in March after neighborhood vigilantes in the provincial capital, Banda Aceh, suspected them of being gay and broke into their rented room to catch them having sex.

A Shariah court last week sentenced each man to 85 strokes, but they were caned 83 times after a remission for time spent in prison. Four heterosexual couples also were caned Tuesday, receiving a far lesser number of strokes for affection outside marriage.

Banda Aceh resident Ibrahim Muhayat said far more people attended the publicly meted-out punishment than usual because like him, many wanted to witness Indonesia’s first-ever caning of gay men.

The Islamic Defenders Front, a hard-line group known for acts of vigilante violence throughout Indonesia, erected a banner at the mosque that declared the group was ready to defend Shariah law whatever the cost.

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 year.

Prejudice has been fanned by stridently anti-gay comments from politicians and Islamic hard-liners, and a case before the country’s top court is seeking to criminalize gay sex and sex outside marriage. On Monday, 141 men were detained in a police raid on a gay sauna in Jakarta, the capital.

ADVERTISEMENT

New York-based Human Rights Watch said the caning was torture under international law and had called on Indonesian President Joko “Jokowi” Widodo to intervene.

The maximum possible sentence was 100 strokes of the cane and prosecutors had asked for 80.

“The court’s less-than-maximum sentence of 85 lashes is no act of compassion. It does not change the reality that flogging is a grotesque display of medieval torture,” said Phelim Kine, deputy Asia director at Human Rights Watch.

Caning is also a punishment in Aceh for gambling, drinking alcohol, women who wear tight clothes and men who skip Friday prayers. More than 300 people were caned for such offenses in 2016.

Indonesia’s reputation for practicing a moderate form of Islam has been battered in the past year due to attacks on religious minorities, a surge in persecution of gays and a polarizing election campaign for governor of Jakarta that highlighted the growing strength of hard-line Islamic groups.

Earlier this month, the outgoing Jakarta governor, a minority Christian, was sentenced to two years in prison for campaign comments deemed as blaspheming the Quran.