The second is expanding use of the HIV prevention pill, Truvada. This has been somewhat controversial. A recent Kaiser study found that some men who took the drug used condoms less and contracted other sexually transmitted diseases. But none got HIV.

Other studies show the drug “could be over 90 percent effective in preventing new infections, if taken on a daily basis,” said Dr. Susan Buchbinder, director of HIV research at the city’s health department. She added there's no reason to withhold a lifesaving preventive drug for fear of promiscuity.

“I liken it to me telling my patients that I'm not going to give them a cholesterol-lowering drug because they might eat more ice cream,” she said. “I would never do that."

San Francisco participated in the first pilot studies for the preventive therapy, also known as Pre-Exposure Prophylaxis (PrEP), and is now a leader in its use, Buchbinder said.

Health officials from Paris and Amsterdam visited San Francisco recently to study the city’s program, in anticipation of the drug getting licensed in Europe.

“Of course, we were a city where HIV started and was discovered, and reached epidemic levels,” said Mayor Ed Lee, “but we're also a city at the forefront of the appropriate response.”

At a time when the federal government continues to cut HIV/AIDS funding, San Francisco consistently backfills the loss, Lee said.

But other counties in California haven’t. In Fresno, for example, HIV infection rates have gone up as funding has been cut. In 2011, new cases of HIV spiked 73 percent over the county’s previous five-year average. Annual rates dipped slightly after that, then went up again last year.

In total, San Francisco spends $54 million on HIV prevention and care each year. In addition to the $1.2 million the city dedicated to the effort from its own coffers this week, the MAC AIDS Fund, a philanthropic arm of the MAC cosmetics company, gave another $500,000 to the city.

Most of the new funding will go toward hiring more patient navigators, who will help patients sign up for health insurance, find a clinic to get care or find resources to help pay for the prevention drugs -- the Truvada daily pill can cost more than $1,000 a month.

The city will focus a lot of its outreach on young men and men of color, who are disproportionately affected by HIV. African-American gay men have the highest rate of new diagnoses.

Johanna Brown, a black transgender woman living with AIDS, remembers how difficult life was after she got her diagnosis.

“I lost my job, I lost my apartment, I got on drugs real heavy,” she said. “I lost my self-esteem, got disconnected from my family.”

She came to San Francisco in 2011 and found the API Wellness Center, where she got a new doctor, therapist and case manager. They helped her get treatment, housing and a job. They also have a special support program for transgender people living with HIV and AIDS.

“There, we as girls get to come together, we get to socialize within ourselves, but we get to learn about our disease,” she said. “We don’t have to be worried about stigma, being judged, people pointing fingers at us. So we live a healthier life.”

Today, Brown’s T-cell count is good, and the virus is undetectable in her blood.

“I'm not dying,” she said. “I'm going to live a long life.”