JAKARTA, Indonesia — Steven Handoko admits it wasn’t his most dignified moment. Naked as the day he was born, the bookish 25-year-old had been invited on stage by one of the strippers hired for a party at the Atlantis Gym.
That hardly qualified as outrageous behavior in the red-light district of Kelapa Gading in North Jakarta, where the Atlantis was located. Nearby were plenty of venues with suggestive names like the Playboy Sensation, massage parlors for straight men. The Atlantis was a gay sauna in a conservative country, but given the generally live-and-let-live milieu of the Indonesian capital’s night life, Mr. Handoko felt safe, if a little embarrassed.
But he wasn’t. Soon after he took the stage, the police stormed the premises. Officers herded naked, cowering men into the middle of the room and began taking photos, some of which — including one of Mr. Handoko — appeared on Indonesian social media within hours. He and 140 other men were taken away.
“When a future employer Googles me, this is what they will see,” Mr. Handoko, an aspiring journalist, said last week in an interview at Cipinang prison in Jakarta, where he has been held since the raid in May.
This week, prosecutors notified Mr. Handoko’s family that he had been sentenced in absentia to two years and three months in prison, convicted of violating Indonesia’s antipornography law, which includes a ban on striptease performances.
In Indonesia, the world’s largest Muslim-majority country, homosexuality has generally been tolerated, if marginalized. But that began to change last year, when the authorities, under pressure from right-wing Islamic groups, started arresting gay men in what experts say are unprecedented numbers, raiding not just bars and saunas but hotel rooms and private apartments.
The crackdown began in November 2016, when the police broke up a party in South Jakarta and detained 13 men. The most recent incident was in October, when 51 men were arrested at what is thought to be Jakarta’s last gay sauna. (The Atlantis closed soon after the raid in May.)
Most of the hundreds of men swept up in the raids were released with no charges filed, and few cases have made it to trial. Nine other detainees from the Atlantis raid were sentenced last week to more than two years in prison.
But even men who weren’t charged have been subjected to humiliating scrutiny and lurid news coverage, with their photos often posted on social media. Indonesian news outlets breathlessly detailed services offered at the Atlantis, like mock jail cells for role playing, and speculated that it was a hub for prostitution.
The authorities have justified the raids by citing the pornography law’s loosely worded ban on material or actions that undermine public decency. Ade Armando, a communications professor at the University of Indonesia who helped draft the pornography statute, said the raids went well beyond the law’s intent.
“It is not fair. It is not right what the police are doing there,” Mr. Armando said. “Hotels are private places. The pornography law does not apply.”
Historically, gay and transgender Indonesians have been accepted — if poorly understood — as long as they married people of the opposite sex and had children, said Tom Boellstorff, an anthropologist at the University of California, Irvine, and author of “The Gay Archipelago: Sexuality and Nation in Indonesia.”
Gay men have been caned in public in the autonomous province of Aceh, where Shariah law is enforced. But in the vast majority of Indonesia, anti-gay violence has been rare, and persecution of gay people by the state has been even rarer. While vigilante groups sometimes got headlines by shutting down gay film festivals or transgender beauty pageants, such violence was not state-sanctioned, Mr. Boellstorff said.
“Most Indonesians had no idea what ‘gay’ meant,” he said. “This just was not on the government’s radar.”
But that has begun to change in the last few years, as Indonesian politicians have seen advantage in appealing to hard-line Islamic sentiment.
In early 2016, the minister of higher education banned an L.G.B.T. student group from the University of Indonesia campus. Later, the broadcasting regulator banned the depiction of gay characters or effeminate men on television.
The defense minister likened homosexuality to nuclear war: While a bomb blast over Jakarta would at least be contained, he said, tolerance for gays could spread dangerously throughout the country. President Joko Widodo spoke up for the rights of L.G.B.T. citizens late last year, but to little avail; the wave of raids began the next month.
Last week, a conservative group’s petition to ban all sex outside marriage, which would have effectively criminalized homosexuality, was narrowly rejected by Indonesia’s Constitutional Court.
Mr. Boellstorff said the current crackdown on gay men had no precedent. “Things are worse now than they have ever been in Indonesian history” for gay people, he said.
Rights advocates had been skeptical that Mr. Handoko and the other Atlantis defendants would get fair trials. The head judge, Pinta Uli Boru Tarigan, was criticized by Human Rights Watch in 2011 for expressing contempt for the Ahmadis, a minority Muslim sect, while overseeing the trial of men charged in a mob attack that killed three of them. Mr. Handoko said Judge Tarigan recounted the story of Sodom and Gomorrah at one of his hearings.
“She had a poor record on human rights,” said Ricky Gunawan, a lawyer for the Community Legal Aid Institute in Jakarta, which specializes in human rights cases.
Mr. Handoko said his family hired a lawyer chosen by the police, and he entered a guilty plea that was essentially a carbon copy of the prosecution’s charges. A sister of Mr. Handoko, who asked not to be identified because she feared repercussions at her workplace, said the family had cooperated in hopes of a lenient sentence.
“We were worried that the court would be like quicksand,” she said. “The more you struggle, the quicker you sink.”
Mr. Handoko’s sister had suspected something was wrong on the night of the Atlantis raid, when he uncharacteristically failed to respond to text messages. The next day, fearing the worst after colleagues said they hadn’t heard from him, she left work early and drove home to be with her mother. On the way, cryptic messages of support began arriving from distant relatives.
At home she found her mother, a devout Christian, in tears — not just because her son had been arrested, but because he was gay.
Many Indonesians have struggled to put the news about the raids into context, because there are few positive examples of gay men in the popular media, Mr. Handoko’s sister said. There is no Indonesian equivalent of “Brokeback Mountain,” she said.
Mr. Handoko’s mother has been supportive since overcoming her initial shock, as have other family members and friends. About once a week, she braves Jakarta’s awful traffic, and the hour or so it takes to wind through security, to visit him in prison. His life there has been a dull routine of exercise, library and church. He said he hadn’t been mistreated.
But Mr. Handoko, referring bitterly to the “It Gets Better” campaign aimed at bullied gay youths, was not optimistic about what the future held for a gay man in Indonesia.
“It doesn’t get better, does it,” he said