Cryptococcal meningitis and other serious fungal infections are common complications in patients infected with the human immunodeficiency virus (HIV). Fluconazole is effective for long-term suppression of many fungal infections, but its effectiveness as primary prophylaxis had not been adequately evaluated. We conducted a prospective, randomized trial that compared fluconazole (200 mg per day) with clotrimazole troches (10 mg taken five times daily) in patients who were also participating in a randomized trial of primary prophylaxis for Pneumocystis carinii pneumonia. After a median follow-up of 35 months, invasive fungal infections had developed in 4.1 percent of the patients in the fluconazole group (9 of 217) and in 10.9 percent of those in the clotrimazole group (23 of 211; relative hazard, as adjusted for the CD4+ count, 3.3; 95 percent confidence interval, 1.5 to 7.6). Of the 32 invasive fungal infections, 17 were cryptococcosis (2 in the fluconazole group and 15 in the clotrimazole group; adjusted relative hazard, 8.5; 95 percent confidence interval, 1.9 to 37.6). The benefit of fluconazole was greater for the patients with 50 or fewer CD4+ cells per cubic millimeter than for the patients with higher counts. Fluconazole was also effective in preventing esophageal candidiasis (adjusted relative hazard, 5.8; 95 percent confidence interval, 1.7 to 20.0; P = 0.004) and confirmed and presumed oropharyngeal candidiasis (5.7 and 38.1 cases per 100 person-years of follow-up in the fluconazole and clotrimazole groups, respectively; P˂0.001). Survival was similar in the two groups. Fluconazole taken prophylactically reduces the frequency of cryptococcosis, esophageal candidiasis, and superficial fungal infections in HIV-infected patients, especially those with 50 or fewer CD4+ lymphocytes per cubic millimeter, but the drug does not reduce overall mortality.