To identify clinical and epidemiological factors associated with failure of Pneumocystis carinii pneumonia (PCP) prophylaxis in those receiving primary and secondary prophylaxis. Longitudinal cohort study of participants infected with human immunodeficiency virus type 1 in the Multicenter AIDS Cohort Study who used PCP prophylaxis regimens after their T-helper lymphocyte counts had decreased to less than 0.200 x 10(9)/L (200/microL). Occurrence or recurrence of PCP. A total of 476 participants reported taking one or more of the following regimens: trimethoprim-sulfamethoxazole (TMP-SMX), dapsone, and/or aerosolized pentamidine--367 as primary prophylaxis and 109 as secondary prophylaxis after a previous episode of PCP. A total of 92 (20%) developed PCP despite prophylaxis. The mean failure rates per person-year of follow-up were 16.0% for those receiving primary prophylaxis and 12.1% for those receiving secondary prophylaxis (P = .19). Median times to death after initiation of primary or secondary prophylaxis were 2.0 and 1.2 years, respectively. The main predictor for failure of PCP prophylaxis was profound T-helper lymphocytopenia; 86% of failures occurred after T-helper cell counts decreased to less than 0.075 x 10(9)/L and 76% occurred after counts decreased to less than 0.050 x 10(9)/L. In multivariate time-dependent analysis, when compared with counts between 0.100 x 10(9)/L and 0.200 x 10(9)/L, the risk ratio for failure with counts less than 0.050 x 10(9)/L was 2.90 (P < .001). Once T-helper cell counts were considered, fever was the only other health status indicator that predicted subsequent PCP (ie, a time-dependent risk ratio of 2.22; P = .01). Use of TMP-SMX as the prophylaxis regimen was protective but did not eliminate failure (ie, a time-dependent risk ratio of 0.55; P = .03). These findings strongly support identifying improved methods of PCP prophylaxis once T-helper cell counts decrease to less than 0.075 x 10(9)/L or 0.100 x 10(9)/L. Given this severe degree of immunosuppression, an inherently more effective regimen against P carinii is required.