A province in Indonesia has passed an anti-homosexuality law punishing gay sex with public caning.

The measure affecting the Aceh province was passed by the 69-member assembly unanimously early on Saturday after hours of debate, in a strict interpretation of Islamic sharia.

The law says anal sex between men is punishable by up to 100 lashes of the cane. Women found guilty of "rubbing" their body parts against each other for sexual pleasure are also liable for the same punishment.

The law also applies to non-Muslims in the overwhelmingly Muslim province. Only one per cent of Aceh residents are non-Muslims.

The bill, which comes just days before a new 81-member regional parliament takes over in Aceh province, also sets out punishment for sex crimes, unmarried people engaging in displays of affection, people caught found guilty of adultery and underage sex.

Human rights groups say the law violates international treaties signed by Indonesia protecting the rights of minorities and women.

Gay rights activist King Oey urged the central government's new moderate leadership to use its influence to overturn the law, or appeal it at the Constitutional Court.

"It's discriminatory and saddening," he said. "We urge people who are concerned with human rights will not sit by silently."

People convicted of adultery, gambling and consuming alcohol already face caning, as do women wearing tight clothes and people who skip Friday Muslim prayers.