A SHARIA court in Indonesia has sentenced two gay men to public caning for the first time, further undermining the country's moderate image after a leading Christian politician was imprisoned for blasphemy.

The court in conservative Aceh province said the men, aged 20 and 23, would each be subjected to 85 lashes for having sexual relations.

One of the men wept and pleaded for leniency at the sentencing which coincided with International Day Against Homophobia and Transphobia.

Chief prosecutor Gulmaini said they will be caned next week, before Ramadan starts.

The couple were arrested in late 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.

Footage that circulated online and formed part of the evidence shows one of the men naked and visibly distressed as he apparently calls for help on his phone.

The second man is repeatedly pushed by another man preventing the couple from leaving the room.

The lead judge, Khairil Jamal, said the men were "legally and convincingly proven to have committed gay sex".

He said the three-judge panel decided against the maximum sentence of 100 lashes because the men were polite in court, co-operated with authorities and had no previous convictions.

Prosecutors had asked that they receive 80 lashes.

"As Muslims, the defendants should uphold the sharia law that prevails in Aceh," Jamal said.

International human rights groups have described the treatment of the men as abusive and humiliating and called for their immediate release. Human Rights Watch said in April that public caning would constitute torture under international law.

Indonesia's reputation for practising a moderate form of Islam has been damaged in the past year due to attacks on religious minorities, a surge in persecution of gays and a polarising election campaign for governor of the capital Jakarta that highlighted the growing strength of hardline 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.

The judges imposed a tougher sentence than that sought by prosecutors who had downgraded the charge from blasphemy and asked for just two years of probation.

"The prosecution is very harsh. The verdict is harsher," said Andreas Harsono, Indonesia researcher for Human Rights Watch. "It shows the increasingly conservative judiciary in Indonesia."

Aceh is the only province in Muslim-majority Indonesia allowed to practice sharia law, a concession made by the national government in 2006 to end a war with separatists, but other some other areas have introduced sharia-style by-laws.

Aceh implemented an expansion of Islamic by-laws and criminal code two years ago that extended sharia law to the province's non-Muslims and allows up to 100 lashes for morality offences including gay sex and sex between unmarried people.

Human Rights Watch says the Aceh laws violate the International Covenant on Civil and Political Rights, which Indonesia ratified in 2005.

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

Homosexuality is not illegal elsewhere in Indonesia but a case before the country's top court is seeking to criminalise gay sex and sex outside marriage.