Background: With a lifetime risk for major depressive disorder of up to 50%, depression is a common comorbidity in multiple sclerosis but remains widely underdiagnosed and untreated. We investigated the potential of a fully automated, internet-based, cognitive behavioural therapy programme, Deprexis, to reduce depressive symptoms in patients with multiple sclerosis. Methods: For this randomised controlled trial, we recruited patients from an outpatient clinic in Hamburg, Germany. Patients aged 18-65 years were eligible for inclusion if they had multiple sclerosis and self-reported depressive symptoms. By use of a computer-generated randomisation sequence, we allocated 90 patients (1:1; no blocking or stratification) to either the intervention group or a waitlist control group for 9 weeks. The primary endpoint was the Beck Depression Inventory (BDI), as assessed by an intention-to-treat analysis. This trial is registered with ClinicalTrials.gov, number NCT01663649. Findings: 71 patients completed the trial: 35 patients in the intervention group and 36 patients in the control group. During the intervention, BDI scores decreased in the Deprexis group and increased in the control group, yielding a positive effect of Deprexis relative to the waitlist group (mean group difference -4·02 points [95% CI -7·26 to -0·79], p=0·015, effect size d=0·53). Worsening of depressive symptoms from below to above the clinical cutoff (BDI >13) occurred in three (7%) of 45 patients in the control group and no patients in the Deprexis group. We noted no adverse events with respect to new occurrence of suicidal ideation during the trial. Interpretation: Psychological online-intervention programmes could be suitable for patients with multiple sclerosis who are unable to regularly attend therapeutic sessions because of mobility impairments. Funding: European Union and the Deutsche Forschungsgemeinschaft.