Diarrhea is frequent among persons infected with human immunodeficiency virus (HIV) but few interventions are available for people in Africa. We conducted a randomized controlled trial of a home-based, safe water intervention on the incidence and severity of diarrhea among persons with HIV living in rural Uganda. Between April 2001 and November 2002, households of 509 persons with HIV and 1,521 HIV-negative household members received a closed-mouth plastic container, a dilute chlorine solution, and hygiene education (safe water system [SWS]) or simply hygiene education alone. After five months, HIV-positive participants received daily cotrimoxazole prophylaxis (160 mg of trimethoprim and 800 mg of sulfamethoxazole) and were followed for an additional 1.5 years. Persons with HIV using SWS had 25% fewer diarrhea episodes (adjusted incidence rate ratio [IRR] = 0.75, 95% confidence interval [CI] = 0.59-0.94, P = 0.015), 33% fewer days with diarrhea (IRR = 0.67, 95% CI = 0.48-0.94, P = 0.021), and less visible blood or mucus in stools (28% versus 39%; P < 0.0001). The SWS was equally effective with or without cotrimoxazole prophylaxis (P = 0.73 for interaction), and together they reduced diarrhea episodes by 67% (IRR = 0.33, 95% CI = 0.24-0.46, P < 0.0001), days with diarrhea by 54% (IRR = 0.46, 95% CI = 0.32-0.66, P < 0.0001), and days of work or school lost due to diarrhea by 47% (IRR = 0.53, 95% CI = 0.34-0.83, P < 0.0056). A home-based safe water system reduced diarrhea frequency and severity among persons with HIV living in Africa and large scale implementation should be considered.