Trimethoprim-sulfamethoxazole (TMP-SMX) is widely used for Pneumocystis carinii pneumonia prophylaxis in human immunodeficiency virus (HIV)-infected patients, but little is known about the effects of this practice on the emergence of TMP-SMX-resistant bacteria. A serial cross-sectional study of resistance to TMP-SMX among all clinical isolates of Staphylococcus aureus and 7 genera of Enterobacteriaceae was performed at San Francisco General Hospital. Resistance among all isolates was <5.5% from 1979 to 1986 but then markedly increased, reaching 20.4% in 1995. This was most prominent in HIV-infected patients: resistance increased from 6.3% in 1988 to 53% in 1995. The largest increases in resistance were in Escherichia coli (24% in 1988 to 74% in 1995) and S. aureus (0% to 48%) obtained from HIV-infected patients. A rapid increase in the use of prophylactic TMP-SMX in HIV disease was also observed during this time in San Francisco and is likely responsible for the increase in TMP-SMX resistance.