Two gay men have been caned 85 times each after they were caught in bed together by a vigilante group in Indonesia.

The pair, aged 20 and 23, who have not been named, were marched on to a stage in white shirts while men dressed head-to-toe in brown robes carried out the sentence.

Hundreds of people in Aceh province, which recognises sharia law as part of its legal system, gathered to watch as the men were beaten outside a mosque in the provincial capital of Banda Aceh on Tuesday.

Two gay men have been given 85 lashes with a cane each after being convicted of having gay sex in Aceh province, Indonesia, which practices Sharia law

The pair, aged 20 and 23, were caught back in March after a vigilante group burst into their home and filmed them in bed together while abusing them

The pair were two of around 10 people to be whipped for various offences in front of a mosque in Banda Aceh, the provincial capital, on Tuesday morning

Up to 1,000 people gathered to watch the sentence carried out - the first time that lashes have been handed out as a punishment for homosexuality in the province

Dozens of people filmed the punishment on their phones, while some taunted the men, saying 'let that be a lesson to you' and urging the whipper to 'do it harder'

While many filmed on their smartphones, others taunted the men, saying 'let that be a lesson to you' and telling the whippers to 'do it harder', the BBC reports.

Organisers warned the crowd not to attack the men, reminding people that 'they are also human'.

Before the sentence was carried out, reporter Rebecca Henschke met with one of the men, who said he was terrified, shaking all over, and had a rash on his skin.

As they spoke in his jail cell, the other inmates crowded around the bars, trying to intimidate him.

Speaking about the punishment, he said: '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.'

Eni Tri Retnaningsih, a 20-year-old student who watched the punishment, said she had seen others caned before for other offences such as adultery

Aceh province was given dispensation to create its own laws more than a decade ago, and in recent years has become far more conservative - outlawing homosexuality in 2015

After the beatings had been carried out, the men were helped from the stage and told they can go home to their families

Men and women were separated in the crowd by religious officials before the sentence was carried out early on Tuesday morning

The men have tried to hide their faces since their arrest, but were forced to hold their hands to their sides during the whipping

'I hope there won't be any more cases of homosexuality, it is shocking,' she said.

At least eight other men and women were caned for other offences ahead of the punishment of the two found guilty of having gay sex.

Police separated men and women in the crowd as proceedings began, with 10 men in brown robes and hoods preparing a bundle of canes in case any broke during the flogging.

The sentence marks the first time that caning has been handed out as a punishment for homosexuality in Aceh province, where it is usually reserved for those caught gambling or drinking.

The beatings were delivered on the clothed backs of the men and women, some of whom cried out in pain with each stroke. In some cases, the caning was suspended briefly if the offender signalled they were in too much pain.

At the end of the lashing, the two men were helped off the platform. They were free to return to their families, authorities said.

The men were caught together in bed in March by thugs who burst into the boarding house where they were staying.

Shaky mobile footage showed the men together in a hostel in the provincial capital Banda Aceh. The thugs who filmed the men beat and taunted them

Police later arrested the distressed couple, who said they were in a relationship and had sex three times

On Monday 141 men were arrested for taking part in a 'gay sex party' in Jakarta, Indonesia's capital, despite the fact that gay sex is not illegal there

Shaky mobile footage of the raid showed the vigilantes kicking, slapping and insulting the men, one of whom was slumped naked on the ground during the attack.

Police later arrested the distressed couple, who said they were in a relationship and had had sex three times.

Handing down the verdict at the Banda Aceh court, presiding judge Khairil Jamal said the men had been 'proven legally and convincingly guilty of committing gay sex, the defendants are sentenced to 85 strokes of the cane in public'.

While homosexuality is not prohibited in the rest of Indonesia, authorities have been cracking down on the LGBT community using loosely-worded pornography laws that can be construed to include erotic dances.

On Monday 141 men, including a British man and a Singaporean, were arrested at the Atlantis sauna and gym in capital Jakarta for taking part in a 'gay sex party'.

Most of them had been released on Tuesday morning, but police say up to 10, including the organisers and dancers, could face charges.

That follows a similar raid in Surabaya, Indonesia's second-largest city, in which 14 men were arrested on similar charges.

Indonesia is the most populous Muslim country in the world, with a population of 260million, 87 per cent of whom follow the religion.