Objectives: First-line therapy for Pneumocystis jirovecii pneumonia (PCP) is trimethoprim/sulfamethoxazole. Few data exist to guide the choice of second-line therapy for patients failing or developing toxicity to first-line therapy. Methods: A case note review of 1122 patients with 1188 episodes of HIV-associated PCP from three observational cohorts in Copenhagen, London and Milan, between 1989 and 2004, was conducted. Results: Trimethoprim/sulfamethoxazole (962 PCP episodes, 81%) was the most frequently used first-line therapy, followed by intravenous pentamidine (87 episodes, 7%), clindamycin/primaquine (72 episodes, 6%) and 'other' (atovaquone, dapsone/pyrimethamine, trimetrexate or inhaled pentamidine; 67 episodes, 6%). Rates of unchanged therapy were trimethoprim/sulfamethoxazole = 79%, clindamycin/primaquine = 65% and pentamidine = 60% (P < 0.001). First-line therapy was changed because of failure in 82 (7%) episodes and because of toxicity in 198 (17%) episodes. Three month survival rates were trimethoprim/sulfamethoxazole = 85%, clindamycin/primaquine = 81% and pentamidine = 76% (P = 0.09). After adjustment for possible confounders, pentamidine was associated with a significantly greater risk of death at 3 months [hazard ratio (HR) = 2.0, 95% confidence interval (CI) = 1.2-3.4]. Second-line therapy survival rates differed: trimethoprim/sulfamethoxazole = 85%; clindamycin/primaquine = 87%; and pentamidine = 60% (P = 0.01). Multivariable time-updated Cox regression analysis showed a greater risk of death associated with pentamidine (HR = 3.3, 95% CI = 2.2-5.0), but not for clindamycin/primaquine, when both were compared with trimethoprim/sulfamethoxazole. Conclusions: Pentamidine was associated with a greater risk of death when used as first- and second-line therapy for HIV-associated PCP, and was associated with more treatment changes. Clindamycin/primaquine appeared superior to pentamidine as second-line therapy for PCP in patients failing or developing toxicity with trimethoprim/sulfamethoxazole. In patients failing first-line treatment with non-trimethoprim/sulfamethoxazole regimens, second-line therapy should be trimethoprim/sulfamethoxazole. © The Author 2009. Published by Oxford University Press on behalf of the British Society for Antimicrobial Chemotherapy.