GENEVA — United Nations officials on Friday condemned the recent mass arrests of gay and transgender people in Azerbaijan, Egypt and Indonesia, saying that the authorities in those countries had violated international law by detaining, mistreating and torturing them.

The roundups — of about 80 people in Azerbaijan, 50 in Egypt and 50 in Indonesia over the past few weeks — do not appear to be connected, but United Nations officials said they exposed patterns of discrimination and abuse that also damage broad development goals.

The authorities in Azerbaijan’s capital, Baku, have detained more than 80 people identified as lesbian, gay, bisexual or transgender since mid-September, reportedly subjecting some of them to beatings, electric shocks and forced shaving, Rupert Colville, a spokesman for the United Nations High Commissioner for Human Rights, told reporters in Geneva.

The police resorted to other forms of humiliation, including forcing many of those arrested to undergo medical examinations and then releasing the results or details of their medical status to the news media.