Background: Bullying, aggression, and violence among children and young people are some of the most consequential public mental health problems. We tested the Learning Together intervention, which involved students in efforts to modify their school environment using restorative practice and by developing social and emotional skills. Methods: We did a cluster randomised trial, with economic and process evaluations, of the Learning Together intervention compared with standard practice (controls) over 3 years in secondary schools in south-east England. Learning Together consisted of staff training in restorative practice; convening and facilitating a school action group; and a student social and emotional skills curriculum. Primary outcomes were self-reported experience of bullying victimisation (Gatehouse Bullying Scale; GBS) and perpetration of aggression (Edinburgh Study of Youth Transitions and Crime (ESYTC) school misbehaviour subscale) measured at 36 months. We analysed data using intention-to-treat longitudinal mixed-effects models. This trial was registered with the ISRCTN registry (10751359). Findings: We included 40 schools (20 in each group); no schools withdrew. 6667 (93·6%) of 7121 students participated at baseline and 5960 (83·3%) of 7154 at 36 months. Mean GBS bullying score at 36 months was 0·34 (SE 0·02) in the control group versus 0·29 (SE 0·02) in the intervention group, with a significant adjusted mean difference (−0·03, 95% CI −0·06 to −0·001; adjusted effect size −0·08). Mean ESYTC score at 36 months was 4·33 (SE 0·20) in the control group versus 4·04 (0·21) in the intervention group, with no evidence of a difference between groups (adjusted difference −0·13, 95% CI −0·43 to 0·18; adjusted effect size −0·03). Costs were an additional £58 per pupil in intervention schools than in control schools. Interpretation: Learning Together had small but significant effects on bullying, which could be important for public health, but no effect on aggression. Interventions to promote student health by modifying the whole-school environment are likely to be one of the most feasible and efficient ways of addressing closely related risk and health outcomes in children and young people. Funding: National Institute for Health Research, Educational Endowment Foundation.