Two men in Indonesia's Aceh province have been publicly caned dozens of times for consensual gay sex.
The punishment was denounced by rights advocates as "medieval torture" and intensifies an anti-gay backlash in the world's most populous Muslim country.
More than 1,000 people packed the courtyard of a mosque to witness the caning, which was the first time that Aceh, the only province in Indonesia to practise Sharia law, has caned people for homosexuality.
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 on mobile phones as a team of five robed and hooded enforcers took turns to inflict 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 neighbourhood 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 on Tuesday, receiving far fewer 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 hardline group known for acts of vigilante violence throughout Indonesia, erected a banner at the mosque which declared that 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 hardliners, and a case before the country's top court is seeking to criminalise gay sex and sex outside marriage. On Monday, 141 men were detained in a police raid on a gay sauna in Jakarta, the capital.
New York-based Human Rights Watch said the caning was torture under international law and called on Indonesian President Joko "Jokowi" Widodo to intervene.
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 offences in 2016.
Indonesia's reputation for practising 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 polarising election campaign for governor of Jakarta which 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 Koran.