Cryptococcal disease remains an important cause of morbidity and mortality in HIV-infected individuals in sub-Saharan Africa, despite the introduction of antiretroviral therapy. We studied fluconazole as primary prophylaxis against cryptococcal disease in patients awaiting or starting antiretroviral therapy in Uganda. In this prospective, double-blind randomised controlled trial, we enrolled HIV-positive adults with CD4 counts less than 200 cells per μL, cryptococcal antigen (CrAg)-negative, naive for antiretroviral therapy, and coming from five local AIDS organisations in Masaka district, Uganda. Enrolment took place between Sept 14, 2004, and Feb 1, 2008. Participants were randomly allocated to placebo or 200 mg fluconazole three times per week (1:1) in blocks of 40. Randomisation was done with ralloc procedure in Stata. Participants were reviewed after 4 weeks and referred for antiretroviral therapy, then seen every 8 weeks. Participants discontinued trial treatment when CD4 counts reached 200 cells per μL (median 197 days). Primary endpoints were invasive cryptococcal disease and all-cause mortality. Secondary endpoints were time to first episode and incidence of oesophageal candidosis, time to first episode and incidence of oropharyngeal or vaginal candidosis, and time to first hospital admission or death. The primary safety endpoint was cessation of trial drug because of transaminase concentrations higher than five times the upper limit of normal (ULN), or other major adverse events. Analyses were done by intention to treat and included all participants enrolled in the trial. Participants and researchers were masked to group assignment. This trial is registered with controlled-trials.com, number ISRCTN 76481529. Of 1519 individuals enrolled, 760 participants received fluconazole and 759 received placebo. 19 developed cryptococcal disease, one in the fluconazole group and 18 in the placebo group (p=0·0001); adjusted HR (aHR) 18·7 (95% CI 2·5-140·7). One case of cryptococcal disease could be prevented by treating 44·6 patients with baseline CD4 counts lower than 200 cells per μL. Fluconazole was effective against cryptococcal disease both before (aHR=11·0 [1·4-85·3]) and after start of antiretroviral therapy (no cases in fluconazole vs seven cases on placebo). Seven participants died from cryptococcal disease, none in the fluconazole group. All-cause mortality (n=189) did not differ between the two groups (p=0·46). Fluconazole reduced the time to first episode of oesophageal, and oropharyngeal and vaginal candidosis, as well as the incidence of all candidosis (p<0·0001), but had no effect on hospital admission or death. The frequency of elevated transaminases (>5×ULN) was similar between groups (aHR=0·94 [0·65-1·35]). Fluconazole was safe and effective as primary prophylaxis against cryptococcal disease, both before and during early antiretroviral treatment. Cryptococcal infection was less common than anticipated because of the rapid commencement of antiretroviral therapy and exclusion of those with positive CrAg. In patients with negative CrAg on screening, fluconazole prophylaxis can prevent cryptococcal disease while waiting for and in the early weeks of antiretroviral therapy, particularly in those with CD4 counts of less than 100 cells per μL. Medical Research Council, UK, and Rockefeller Foundation.