Pneumocystis carinii pneumonia (PCP) is the most frequent life-threatening opportunistic infection associated with human immunodeficiency virus (HIV) infection. To assess the possible value of aerosolized-pentamidine prophylaxis in different doses, a controlled clinical trial was begun in 1987 with 408 subjects at 12 treatment centers. The participants were randomly assigned to receive 30 mg of pentamidine every two weeks, 150 mg every two weeks, or 300 mg every four weeks. Eighteen months after randomization, the subjects in the 300-mg arm had had 8 confirmed episodes of PCP while receiving treatment, as compared with 22 in the 30-mg arm (P = 0.0008). The 150-mg arm had intermediate results but ones not significantly different from those of the 300-mg arm. Participants with previous episodes of PCP and CD4-cell counts less than 200 per cubic millimeter were at the highest risk for PCP. Aerosolized pentamidine was effective for prophylaxis against PCP in patients infected with HIV, according to the dose and schedule of administration. It and zidovudine were well tolerated together and had independent prophylactic benefits.