Two young gay men have been sentenced by a religious court in the Indonesian province of Aceh to receive 85 strokes of the cane during a public ceremony.

The men, aged 20 and 23, are the first people to be convicted of homosexuality in Indonesia. They were prosecuted under Aceh's strict sharia code.

The sentence is greater than the original prosecution demand of 80 strokes each.

The men will be caned during a public ceremony on May 23 in the city of Banda Aceh, just before the beginning of the holy Islamic month of Ramadan.

Their punishment will be delivered by a hooded government official known as "algojo" — literally, the executioner.

Men arrested after violent assault caught on video

The pair have been in custody since early April, when a group of neighbourhood vigilantes broke down the door of the home of one of the men and found them in bed together.

The vigilantes filmed themselves kicking, slapping and insulting the pair with taunts like "you are a man — why do you look like this?"

In the video, the young men plead with their accusers not to report them to the sharia police.

Sorry, this video has expired Indonesian vigilantes detain, punch and kick two men they accuse of being gay

The video was not part of the evidence presented to the judges.

The evidence shown to the court included the mens' clothing and three condoms.

The men were tried before a three-judge panel in a closed court, but prosecution documents obtained by the ABC show the pair were punished for damaging the province's reputation.

"The deeds of the defendants creates a bad image of the Aceh people and community," the documents stated.

Aceh was granted autonomy to introduce sharia law under a peace deal with the Indonesian Government to end civil war in the province.

Unmarried heterosexual couples are regularly prosecuted and caned for offences such as being alone in the same room with each other.

Last year the ABC witnessed an 18-year-old woman who received nine strokes after she was caught alone in a room with her boyfriend.

The two Aceh men face a maximum punishment of 100 strokes of the cane, but the prosecution said they should receive 80 strokes because they were young and had admitted their guilt.