The course of pneumonia caused by pyogenic bacteria and Pneumocystis carinii was examined in a multicity cohort study of HIV infection. The median duration of survival among 150 individuals following initial bacterial pneumonia was 24 months, compared with 37 months among 299 human immunodeficiency virus (HIV)-infected control subjects matched by study site and CD4 lymphocyte count (P<.001). For 152 subjects with P. carinii pneumonia, median survival was 23 months, compared with 30 months for 280 matched control subjects (P = .002). Median durations of survival associated with the two types of pneumonia differed by only 47 days, despite a higher median CD4 lymphocyte count associated with bacterial pneumonia. These results suggest that both P. carinii pneumonia and bacterial pneumonia are associated with a significantly worse subsequent HIV disease course. The similarity of prognosis after one episode of bacterial pneumonia vs. an AIDS-defining opportunistic infection and the proportion of cases occurring in association with a CD4 lymphocyte count of >200 suggest that measures to prevent bacterial pneumonia should be emphasized.