Media playback is unsupported on your device Media caption Aceh is the only province in Muslim-majority Indonesia that practises Sharia law.

Two men have been caned 83 times each in the Indonesian province of Aceh after being caught having sex.

The men stood on stage in white gowns praying while a team of hooded men lashed their backs with a cane.

The pair, aged 20 and 23, were found in bed together by vigilantes who entered their private accommodation in March. They have not been identified.

Gay sex is not illegal in most of Indonesia but it is in Aceh, the only province which exercises Islamic law.

It is the first time gay men have been caned under Sharia law in the province.

The punishment was delivered outside a mosque in the provincial capital of Banda Aceh.

Image copyright Junaidi

A large crowd of observers cheered as the caning took place. "Let this be a lesson to you," one of the men watching cried out. "Do it harder," another man yelled.

Earlier, an organiser warned the crowd not to attack the men, saying "they are also human".

The men were sentenced to 85 strokes but the number was reduced by two because they had spent two months in detention.

'He was terrified' - Rebecca Henschke, BBC News, Banda Aceh

I met one of the young men in jail a day before the caning, the first journalist to speak to him. He was terrified and his whole body was shaking. He was thin, pale and had a red rash on his skin.

Inmates surrounded us with intimidating glares as we tried to talk. I thought we were going to be speaking in a private room, but he was not granted that.

Before neighbourhood vigilantes broke down the door to his rented room, he was in his final years of a medical degree - his plan was to be a doctor. Now we are told the university has kicked him out.

Videos of the raid that caught him and his partner having sex have been widely shared online. In the mobile phone footage they are both naked, pleading for help.

"I just want the caning to be over and to go back to my family, I have been deeply depressed. I am trying to pull myself out of a deep black hole," he said.

The countries that cane their convicts

Aceh was granted special rights to introduce its own stricter Islamic laws more than a decade ago, and has become increasingly conservative in recent years.

Strict laws against homosexuality were passed in 2014 and came into effect the following year.

In the past public caning sentences have been handed down only for gambling and drinking alcohol.

Indonesia has historically largely been tolerant of homosexuality, but has witnessed increasing official and social hostility towards its small and low-profile LGBTQ community in recent years.

Image copyright Junaidi

Earlier this month, Indonesian police arrested 14 people in the city of Surabaya for allegedly holding a gay party. They could face charges under ambiguous anti-pornography laws.

On Monday, 141 men were arrested - including a British man - in a raid on what police said was a "gay party" at a sauna in the capital, Jakarta, on similar charges. Most were released on Tuesday.

Rights groups have strongly criticised prosecutions of people involved in same-sex relationships, and the use of caning.

Amnesty International said every human was entitled to a right to privacy and to have consensual relations, but that the two men had been ambushed in their home.

It said caning was a "cruel, inhuman and degrading punishment" and may amount to torture and called on the Acehnese authorities to abandon the practice.