Background Clostridium difficile infection is the most common health-care-associated infection in the USA. We assessed the safety and efficacy of ridinilazole versus vancomycin for treatment of C difficile infection. Methods We did a phase 2, randomised, double-blind, active-controlled, non-inferiority study. Participants with signs and symptoms of C difficile infection and a positive diagnostic test result were recruited from 33 centres in the USA and Canada and randomly assigned (1:1) to receive oral ridinilazole (200 mg every 12 h) or oral vancomycin (125 mg every 6 h) for 10 days. The primary endpoint was achievement of a sustained clinical response, defined as clinical cure at the end of treatment and no recurrence within 30 days, which was used to establish non-inferiority (15% margin) of ridinilazole versus vancomycin. The primary efficacy analysis was done on a modified intention-to-treat population comprising all individuals with C difficile infection confirmed by the presence of free toxin in stool who were randomly assigned to receive one or more doses of the study drug. The study is registered with ClinicalTrials.gov, number NCT02092935. Findings Between June 26, 2014, and August 31, 2015, 100 patients were recruited; 50 were randomly assigned to receive ridinilazole and 50 to vancomycin. 16 patients did not complete the study, and 11 discontinued treatment early. The primary efficacy analysis included 69 patients (n=36 in the ridinilazole group; n=33 in the vancomycin group). 24 of 36 (66·7%) patients in the ridinilazole group versus 14 of 33 (42·4%) of those in the vancomycin group had a sustained clinical response (treatment difference 21·1%, 90% CI 3·1–39·1, p=0·0004), establishing the non-inferiority of ridinilazole and also showing statistical superiority at the 10% level. Ridinilazole was well tolerated, with an adverse event profile similar to that of vancomycin: 82% (41 of 50) of participants reported adverse events in the ridinilazole group and 80% (40 of 50) in the vancomycin group. There were no adverse events related to ridinilazole that led to discontinuation. Interpretation Ridinilazole is a targeted-spectrum antimicrobial that shows potential in treatment of initial C difficile infection and in providing sustained benefit through reduction in disease recurrence. Further clinical development is warranted. Funding Wellcome Trust and Summit Therapeutics.