A new political will is driving the city’s turnaround.

“D.C. used to be a bureaucratic nightmare,” said Dr. Anthony S. Fauci, director of the National Institute of Allergy and Infectious Diseases, which is just three subway stops outside the city, in Bethesda, Md. When Adrian M. Fenty took office as the mayor of Washington in 2007, Dr. Fauci said, “it was a whole new morning in America.”

The change is evident on many fronts. The number of H.I.V. tests given has tripled to 122,000 a year, from 43,000 in 2007. The city gave away five million male and female condoms last year, 10 times as many as it did in 2007. More than 300,000 clean needles a year are given away, both to heroin users and to an even higher risk group: transgender prostitutes who inject hormones.

Patients are being found in earlier stages of their illness, when it is more treatable. And 89 percent of those who test positive see a doctor within three days. Under the city’s Red Carpet program, nonprofit organizations are paid to drive new patients to the doctor.

Washington has some major advantages over rival cities. Almost 94 percent of its residents have health insurance, second only to Massachusetts. And there are no waiting lists for AIDS drugs or addiction treatment.

Also, Washington has switched from anonymous to name-based testing, so it can better track infection trends. And in 2007, Congress, which oversees the city’s administration, dropped its ban on clean-needle distribution; since then, infections attributed to dirty needles have plunged by 72 percent.

Black men here are the hardest hit: 6.3 percent in Washington are infected, a rate that rises to more than 30 percent for middle-aged black gay and bisexual men. Even so, the Black AIDS Institute just named Washington one of “the three best cities to be a black gay man in,” based largely on available medical care. (The others were New York and Los Angeles.)

Still, the city has tremendous weaknesses.

Washington finances 70 nonprofit groups, and their effectiveness varies greatly. Each has its own executive salaries, ingrained habits and political patrons. Some are excellent, some have sunk in financing scandals, and some are “left over from the days when all they did was hold people’s hands and watch them die,” said Dr. Gregory Pappas, chief of AIDS for the city’s health department. “The game has changed — but some, God bless them, are the same old people doing the same old things.”