ZANZIBAR — Mohamed had just finished a beer at one of the cluster of bars popular with gay men, just beyond touristy Stone Town. It was around midnight on a Friday in December last year, and he noticed a police officer he knew — Zanzibar is like a small town; most gay men know the local police, and the officers know them. Mohamed waved hello, but the officer ignored him. A minute or two later, another officer approached Mohamed, accused him of being a prostitute, and told him he was under arrest. Mohamed sniffed and handed the officer, whom he’d never seen before, his wallet. “Look in it, and see if it is the wallet of a person who sells himself,” he remembered saying.

At a bar across the road, Mudathir was celebrating his 19th birthday with about a dozen friends. Men were swaying their hips and twirling their arms to live taarab, a soulful orchestra-backed Swahili music, when a group of police officers approached them. The officers were wearing street clothes and, unexpectedly, spoke with mainland accents. “There were a lot of men there [in the club] apart from us, but the police were being shown who to arrest: that one, this one, just like that,” said Khamis, one of the birthday guests. Mudathir, Khamis, and two of their friends were accused of “laziness and loitering” and escorted to a squad car.

By the end of that night, gay men had been arrested all over the island. They spent the weekend in jail, at two different police stations. In his cell, Abdallah, one of Mudathir’s birthday guests, thought that something was off. He had always known he could be arrested for being gay, but expected he would have to pay a bribe and that would be that. But as the hours ticked by, none of the officers made the requisite gesture. Abdallah wondered whether something bigger, something scarier, was happening.

On Monday, they were taken to Zanzibar’s Mnazi Mmoja public hospital — where a doctor told them to crouch on top of a narrow examination bed and raise their buttocks — and forced to go through anal exams. Khamis said the exam lasted for about three minutes, and it felt like he had “gone somewhere and gotten raped.”

The doctor performed the exam, and a police officer supervised. “They just look at you,” Khamis said, indicating with his hands that the doctor had placed his palms on each of his buttocks and spread them. He said he didn’t protest because, with the officer there, he figured raising his voice was futile. “You just follow the way a flag follows the wind. Whatever they told us to do, we did.”

Gay sex has been a crime in Tanzania, punishable with life in prison, since British colonial rule, but there is no record of anyone serving serious time for it. LGBT Tanzanians have always been able to quietly go about their lives, despite stigma and discrimination. But now the Tanzanian government is getting aggressive. About 12 men were arrested that night. (BuzzFeed News spoke to four of them and is using only their first names to protect their identities.) Government ministers have threatened to release lists of LGBT people across Tanzania, and health workers say it’s begun interfering with HIV prevention and treatment.

Tanzania’s crackdown could not have come at a worse time. With the election of Donald Trump and the ascent of nativist movements in Europe, LGBT rights advocates worry that the Trump administration will surrender the US's role as a global leader in pressuring foreign governments to recognize the rights of their LGBT citizens. “It's just a right-wing world at the minute. I doubt [Western leaders] will raise their voices on anything,” said Lotti Rutter of South Africa's Treatment Action Campaign, a leading HIV group on the continent.

That’s left the men arrested that night in Zanzibar all on their own. The case against them remains open, which means they must make regular trips to the police station. They don’t know if they’ll ever be prosecuted.

But the real damage to men like Khamis was done in the exam room. The test felt like a violation, and he was afraid that it might in fact “prove” he was gay. He said he didn’t mind being gay out in the world, but at home he had assured everyone he had stopped dating men. His parents were pushing him to get married. What if the test proved to his family that he’d been lying? “It was as though I had reopened an old wound, as though a dead man had awoken to terrify people,” he said.

Nicky Woo for BuzzFeed News

Khamis poses for a portrait in Zanzibar.

Khamis’s reaction is exactly why LGBT activists and lawyers consider anal exams a violation of human rights. It’s been conclusively shown, they say, that the exams can prove nothing, and the victims of this treatment often feel they have been assaulted.

But none of this bothers Hamisi Kigwangalla, the deputy health minister of Tanzania and the most vocal defender of the crackdown. In fact, his only problem with anal testing is that it doesn’t go far enough. “It cannot be proven whether he did it today or yesterday or the day before,” he told BuzzFeed News by telephone. But “speaking as a medical practitioner, I say yes, one can be examined physically for whether he has engaged in sexual activities unnaturally.”

Only eight countries in the world use anal testing, according to a Human Rights Watch report, and until December, Tanzania was not one of them. But in an exclusive interview with BuzzFeed News, Kigwangalla said he expected anal testing to become routine.

“People will be arrested if there is information that people are indulging themselves in unnatural sexual activities. We should expect that [these] people will be … questioned and physically examined,” he said. “This is a country with laws.”

“I was targeting only those who were promoting homosexuality.”

Kigwangalla frequently takes to Twitter to say that gay people will be rounded up and arrested — and to occasionally swat away allegations of prejudice. Earlier this year, he scheduled a press conference at which he promised to release the names of LGBT Tanzanians; he abruptly canceled. “I was targeting only those who were promoting homosexuality,” he told BuzzFeed News.

But pressed for examples of how public health organizations or individuals are “promoting homosexuality,” the deputy minister demurred: “I cannot mention them because this is sort of a classified information.”

Local activists fear Tanzania is going the way of Uganda, the poster child of homophobia in Africa. In 2010, the Ugandan government published names and pictures of people it said were gay in a local newspaper, an exposure that endangered those people around the same time when the legislature was debating the death penalty for gay men and lesbians. But in Tanzania, people fear the crackdown could be worse. “This is not the era of Hillary Clinton running State, where she could come in heavy-headed to Uganda,” said Sean Maher, a senior HIV adviser at the Boston-based public health consultant John Snow, Inc., who has done work in Tanzania. The US approach is credited with helping roll back Uganda’s most aggressive moves against LGBT people, but there’s no sign — and from LGBT advocates, no faith — that the Trump administration will continue that diplomacy.

The crackdown has drastically changed how gay men, along with sex workers and drug users, interact with Tanzania’s health care system. On Zanzibar, for example, gay men used to visit health centers run by NGOs for checkups, free condoms, and lubricants. Now they are directed to Mnazi Mmoja — the hospital where Khamis and his friends were forced to undergo anal testing. “There, we know all the doctors,” Khamis said. And they’re not known for their compassion. “You go with your heart in your hands.”

Public health experts say the assault on LGBT rights will drive HIV patients underground, cutting them off from life-saving drugs and making it more likely that they will infect their partners. That could reverse Tanzania’s extraordinary gains: The country has reduced its infection rate by more than 30% in just over a decade and provides antiretroviral drugs to half of the 1.4 million infected adults. “Tanzania was a model in the region in terms of how it was responding to key populations until last year,” said a public health partner working in Tanzania who declined to be named. “The status at the moment is lots of confusion… We could say at least hundreds of people are no longer accessing health services because they fear being arrested.”

Tanzania doesn’t track patients from clinic to clinic, so it’s impossible to confirm that estimate, but health staff say they’ve seen this, too, and they know the problem will have major knock-on effects: Patients who don’t take their ARVs can become resistant to the drugs, and their viral load can spike, making transmission more likely. That, in turn, creates an even more expensive problem: While prices vary, the cost of second-line treatment can be double the price of the first.

Public health groups and international organizations have proceeded cautiously and, fearful of antagonizing the Tanzanian government, most of the key players declined to be interviewed on the record. “We have been consistent in expressing concern about the statements and actions taken by certain Tanzanian officials targeting health care providers and civil society organizations that provide services to key populations at risk of HIV/AIDS,” a US State Department official said in a statement. “We urge Tanzania to continue to engage with all stakeholders and to maintain its prior commitments to combat the HIV/AIDS epidemic, and to serve all of its people and populations equally without bias or discrimination.”

Asked if Tanzania risked reversing the strides it has made in fighting HIV/AIDS, Kigwangalla, the deputy health minister, told BuzzFeed News: “As a public health specialist myself, I share similar concerns. But again I am charged with the responsibility of protecting and supervising the administration of the laws of our country.”

Nicky Woo for BuzzFeed News

Khamis and his friends were taken to a hospital for anal exams.

It all began last June when a trans woman went on a local TV station to discuss her life as a sex worker. Godfrey Majunga, who went by Kaoga, told Clouds TV during her interview that she would visit NGOs for health care and for free lubricants and condoms. “If I didn't use them, I don't know where I'd be on this earth,” she said. But the government said a man who “claimed” to be a woman had “glorified gayism” on national television.

The condemnation against the station’s decision to interview Kaoga was so fast and so furious that some activists whispered government officials might have planted the interview to fuel an anti-LGBT backlash. A member of parliament, Amina Mollel, said the TV station had “broken Tanzania’s morals and ethics by glorifying gayism” — the favored bureaucratic pejorative for being gay. Tanzania’s Communications Regulatory Authority forced the station to air an apology for five straight days. (Kaoga could not be reached for comment.)

In July, Tanzania launched a witch hunt against anything it branded as “promoting gayism.” The government banned NGOs from importing and distributing lubricants because it believed they encourage gay sex and, by that logic, spread disease. (The lubricant ban is under review, and the government is expected to release new guidelines soon.) Clinics that serve “at risk” groups, like men who have sex with men, were accused of encouraging gay sex. NGOs that worked with the LGBT population were threatened with closure and dozens of drop-in clinics were shut down.

“It may not be a passing phenomenon as we have seen in some places.”

Despite the obvious health consequences, Kigwangalla was unapologetic about the crackdown. “We said we were going to stop for a while allowing NGOs dealing with [the LGBT population] because we thought they are going overboard and they are promoting homosexuality,” he said.

The extent of the fallout has been difficult to document because fear has shut people up. Groups working on HIV issues are scared to go on the record about anything that might relate to “the gays” — to acknowledge publicly even that gay people exist, let alone that they need health care. Local gay rights activists have been reluctant to speak, too, and those who do ask to meet in secluded areas, where they speak in hushed voices. “I’m not a gay rights activist,” one openly gay activist said toward the end of an hour-long interview about gay rights. Instead, he recast himself as working with “at-risk communities.” In Tanzania today, simply acknowledging that LGBT people exist opens the door to accusations of “promoting homosexuality.”

It’s unclear what, exactly, the government led by President John Magufuli, who was elected in 2015, hopes to accomplish with the crackdown. Until his administration’s anti-gay crusade, Magufuli was best known for his fierce commitment to cutting spending, which also became fuel for internet satire that spread with the hashtag #WhatWouldMagufuliDo. A lot of the laughter has since quieted as Magufuli has become increasingly authoritarian. His quest to “clean up” Tanzania is no longer merely about sacking corrupt officials; it's also about regulating vice. So when an openly trans woman went on TV to talk about her life, a new target of Magufuli’s anti-vice campaign presented itself.

LGBT people are an easy target for that kind of campaign. But the political utility of that prejudice is unclear — and that’s what worries activists the most. In Uganda, politicians rallied against gay rights to win an edge in parliamentary and presidential elections, but there’s no national vote coming any time soon in Tanzania. No one knows what, precisely, Tanzania’s politicians will gain from anti-gay measures that aren’t timed to an election cycle. “Which means,” said Neela Ghoshal, a Human Rights Watch researcher, “that it may not be a passing phenomenon as we have seen in some places.”

Nicky Woo for BuzzFeed News

A “don't ask, don’t tell” attitude has prevailed in Zanzibar long enough that a generation of young gay guys have become accustomed to being able to live openly. They might get harassed on the streets and face family pressure, but they also know that at certain restaurants and taarab bars they can behave however they choose, and be fine. The crackdown — and the police sweep in December — has shaken that confidence. These days, the taarab bars put on performances to smaller crowds. Many of their regulars are staying home, convinced this is a time to duck into the shadows.

You can see it even on the dance floor of Kwaraju music hall, which is on that strip of bars near Stone Town. Saturday nights here used to be loud and sweaty, but on a recent weekend, only a few dozen people sat scattered around the open-air space, most of them quietly drinking beer. The singer was giving a half-hearted performance. Barely anyone was dancing. Abdullah, a gay rights activist, looked around, leaned in, and spoke in a hushed voice. “This place is usually full of people,” he said. “Now, gay people are not going out.”

Since December, many gay men on Zanzibar have retreated into the shadows. Abdallah, one of the men who was arrested, is not one of them. He wanted to be interviewed at Forodhani Gardens, a park and fish market in the heart of Stone Town and perhaps the most public place in all of Zanzibar. Tables are spread thick with grilled octopus and prawns and fresh-squeezed sugar cane, and hawkers eyeball everyone who lingers in the market, shouting out a friendly “Jambo!” and hoping to lure people over. Fearless, muscular teens line up on the sea wall for a turn to dive into the ocean. Tourists and locals loiter and gawk. Everyone sees and is seen by everyone.

Even in this busy crowd, Abdallah stood out. In a tight-fitting T-shirt and tailored trousers made from brightly colored African fabric, he moved with swagger, head raised and shoulders arched back. The activist Abdullah, who had come along to translate, is more cautious. He is a few years older, speaks English, and, as Abdallah told his story about the arrest and the examination at the hospital, acted as his guardian. With every detail of the arrest he described, Abdallah grew even more animated, and his voice got louder. Each time, the activist would bring his finger to his lips and whisper “Shhhhh.” Abdallah would roll his eyes — but obey.

Reporting for this story was supported by the International Reporting Project.

Edith Honan is a journalist based in Nairobi and was previously a staff correspondent for Reuters.