Background. The need to engage boys in gender-transformative relationships and sexuality education (RSE) to reduce adolescent pregnancy is endorsed by WHO. We aimed to test an intervention which used a gender-transformative approach to engage adolescents in RSE to prevent unprotected sex. Methods. This cluster-randomised trial with process and economic evaluations tested a school-based intervention entitled If I Were Jack versus standard RSE (control) for students (aged 14–15 years) in UK schools. Schools were randomly allocated (1:1) and masked to allocation at baseline. The primary outcome was self-reported avoidance of unprotected sex (sexual abstinence or use of reliable contraception at last sex) after 12–14-months. We analysed the data using intention-to-treat mixed effects regression models. Findings. Of 803 schools assessed for eligibility, 263 schools were invited by letter, of which 66 schools agreed to be randomly assigned, of which 62 schools completed follow-up. The trial was done between Feb 1, 2018, and March 6, 2020. 8216 students participated at baseline in 2018; 6561 (79·85%) provided 12–14 months follow-up. There was no significant difference in the primary outcome of avoidance of unprotected sex: 2648 (86·62) of 3057 in the intervention group avoided unprotected sex versus 2768 (86·41%) of 3203 in the control group (adjusted odds ratio [aOR] 0·85 [95% CI 0·58–1·26], p=0·42). Exploratory post-hoc analysis of the two components of the primary outcome showed that significantly more intervention students used reliable contraception at last sex compared with control students and there was no significant difference between the groups for sexual abstinence. No adverse events were reported. Interpretation. The intervention had a null effect on the primary outcome of preventing unprotected sex (increasing sexual abstinence or use of reliable contraception) in the whole student population. However, the results showed significant increases in use of reliable contraceptives for sexually active students. Engaging all young people early through RSE is important so that as they become sexually active, rates of unprotected sex are reduced.