Objective: To assess the efficacy and safety of trimethoprim-sulfamethoxazole for the prevention of spontaneous bacterial peritonitis in patients with cirrhosis and ascites. Design: A randomized controlled trial. Setting: University-affiliate Veterans Affairs medical center. Patients: 60 consecutive patients with cirrhosis and ascites. Interventions: Consecutive patients were randomly assigned to receive either no prophylaxis or trimethoprim-sulfamethoxazole, one double-strength tablet daily, five times a week (Monday through Friday). Patient entry was stratified by serum bilirubin (>51 mu mol/L [>3 mg/dL]), ascitic fluid protein (<1 g/dL), and serum creatinine (>177 mu mol/L [>2 mg/dL]) levels to ensure that high-risk patients would be similarly distributed in the two groups. The median duration of follow-up for the study patients was 90 days. Main Outcome Measures: Spontaneous bacterial peritonitis or spontaneous bacteremia as defined by objective criteria. Results: Spontaneous bacterial peritonitis or spontaneous bacteremia developed in 27% (8 of 30) of patients who did not receive prophylaxis compared with 3% (1 of 30) of patients receiving trimethoprim-sulfamethoxazole (P = 0.025). Overall, infections developed in 9 of 30 patients (30%) not receiving prophylaxis and in 1 of 30 patients (3%) receiving trimethoprim-sulfamethoxazole (P = 0.012). Death occurred in 6 of 30 patients (20%) who did not receive prophylaxis and in 2 of 30 patients (7%) who received trimethoprim-sulfamethoxazole (P = 0.15). Side effects-particularly, hematologic toxicity-could not be attributed to trimethoprim-sulfamethoxazole in any patient. Conclusions: Trimethoprim-sulfamethoxazole was efficacious, safe, and cost-effective for the prevention of spontaneous bacterial peritonitis in patients with cirrhosis.