To measure the effect of trimethoprim-sulfamethoxazole (TMP-SMX) in preventing bacterial illness, Pneumocystis carinii pneumonia (PCP), and death in people with AIDS, we conducted a retrospective medical record review of 1078 persons who were observed for 3 years on average who attended nine outpatient facilities in Seattle, Washington between January 1990 and April 1996. We calculated relative risk estimates to measure the protective effect of TMP-SMX on the development of major bacterial illnesses, PCP, and death. Use of TMP-SMX decreased the risk of PCP (relative risk [RR] = 0.23; 95% confidence interval [CI], 0.14-0.36) and deaths not attributable to PCP (RR = 0.59; 95% CI, 0.47-0.73). Prevention of major bacterial illnesses of known etiology was of borderline significance (RR = 0.77; 95% CI, 0.57-1.05) and became statistically significant with the addition of patients with infections of unknown etiology (RR = 0.77; 95% CI 0.61-0.97). Use of TMP-SMX PCP prophylaxis significantly reduced the risks of death and of PCP and was associated with a trend toward reduced risk of major bacterial infections.