/ Updated  / Source: Associated Press

The United Nations' human rights office is calling on Indonesian authorities to release people detained on the basis of their sexual orientation and combat anti-gay stigma.

Spokesman Rupert Colville said in Geneva on Friday that the office is "concerned by the recent persecution, arbitrary arrest, detention and ill-treatment of men perceived to be gay."

Police and security are seen outside the club where police detained 141 men for what they described as a gay prostitution ring in Jakarta, Indonesia May 23, 2017.DARREN WHITESIDE / Reuters

Homosexuality is not illegal in Indonesia except in Aceh province, but the LGBTQ community has come under siege in the past year. A case before the country's top court seeks to criminalize gay sex.

Related: Two Men Publicly Caned in Indonesia for Having Gay Sex

Colville says that "consensual relations between adults of the same sex should not be criminalized."

He urges Indonesia to review "legislation that contravenes Indonesia's legal obligations, including local criminal legislation in Aceh."

Follow NBC Out on Twitter, Facebook and Instagram