Background: The rising number of young people going to university has led to concerns about an increasing demand for student mental health services. We aimed to assess whether provision of mindfulness courses to university students would improve their resilience to stress. Methods: We did this pragmatic randomised controlled trial at the University of Cambridge, UK. Students aged 18 years or older with no severe mental illness or crisis (self-assessed) were randomly assigned (1:1), via remote survey software using computer-generated random numbers, to receive either an 8 week mindfulness course adapted for university students (Mindfulness Skills for Students [MSS]) plus mental health support as usual, or mental health support as usual alone. Participants and the study management team were aware of group allocation, but allocation was concealed from the researchers, outcome assessors, and study statistician. The primary outcome was self-reported psychological distress during the examination period, as measured with the Clinical Outcomes in Routine Evaluation Outcome Measure (CORE–OM), with higher scores indicating more distress. The primary analysis was by intention to treat. This trial is registered with the Australia and New Zealand Clinical Trials Registry, number ACTRN12615001160527. Findings: Between Sept 28, 2015, and Jan 15, 2016, we randomly assigned 616 students to the MSS group (n=309) or the support as usual group (n=307). 453 (74%) participants completed the CORE–OM during the examination period and 182 (59%) MSS participants completed at least half of the course. MSS reduced distress scores during the examination period compared with support as usual, with mean CORE–OM scores of 0·87 (SD 0·50) in 237 MSS participants versus 1·11 (0·57) in 216 support as usual participants (adjusted mean difference −0·14, 95% CI −0·22 to −0·06; p=0·001), showing a moderate effect size (β −0·44, 95% CI −0·60 to −0·29; p<0·0001). 123 (57%) of 214 participants in the support as usual group had distress scores above an accepted clinical threshold compared with 88 (37%) of 235 participants in the MSS group. On average, six students (95% CI four to ten) needed to be offered the MSS course to prevent one from experiencing clinical levels of distress. No participants had adverse reactions related to self-harm, suicidality, or harm to others. Interpretation: Our findings show that provision of mindfulness training could be an effective component of a wider student mental health strategy. Further comparative effectiveness research with inclusion of controls for non-specific effects is needed to define a range of additional, effective interventions to increase resilience to stress in university students.