For decades, Uganda’s campaign against H.I.V. was exemplary, slashing the country’s death rate by nearly 90 percent from 1990 to 2019. Now a sweeping law enacted last year, the Anti-Homosexuality Act, threatens to renew the epidemic as L.G.B.T.Q. citizens are denied, or are too afraid to seek out, necessary medical care.

The law criminalizes consensual sex between same-sex adults. It also requires all citizens to report anyone suspected of such activity, a mandate that makes no exceptions for health care providers tending to patients.

Under the law, merely having same-sex relationships while living with H.I.V. can incur a charge of “aggravated homosexuality,” which is punishable by death.

Anyone who “knowingly promotes homosexuality” — by hiring or housing an L.G.B.T.Q. person, or by not reporting one to the police — faces up to 20 years in jail. Scores of Ugandans have been evicted from homes and fired from jobs, according to interviews with lawyers and activists.

Entrapment and blackmail — sometimes by the police — are rampant in person, on social media and on dating apps, according to interviews with dozens of people.

L.G.B.T.Q. people, and the advocates and health care workers helping them, have been subject to threats and violence.