BackgroundMental ill-health is very common among people in prison. However, although mental wellbeing features high in health and justice policies, it has been little studied in this population. This study aimed to address this gap using a routine survey of people in prison in Scotland. MethodsThe Warwick-Edinburgh Mental Wellbeing Scale (WEMWBS) is a validated self-report measure of wellbeing scored from 14 (lowest wellbeing) to 70 (highest wellbeing). Since 2013, WEMWBS has been included in the Scottish Prisoner Survey, a biennial self-completed survey distributed to all people in custody in Scotland in paper format. We analysed data from survey sweeps from 2013, 2015, and 2017, using Student's t test to assess differences in mean WEMWBS score by sex and custodial status (sentenced or on remand) and ANOVA for age group. Comparisons with the population in private households were made using Scottish Health Survey data, stratified by age, sex, and deprivation quintile. FindingsWEMWBS data were available for 3158 of 6895 individuals in 2013 (46% of Scottish prison population), 2892 of 6915 in 2015 (42%), and 2405 of 6837 in 2017 (35%). Mean WEMWBS scores for the total sample were 43·4 in 2013 (SD 12·3), 41·8 (12·0) in 2015, and 41·2 (12·3) in 2017. People on remand had lower mean scores than did people sentenced (38·9 [SD 11·9] vs 44·5 [12·1] in 2013, 38·9 [11·3] vs 42·5 [12·1] in 2015, and 37·4 [12·0] vs 42·2 [12·1] in 2017; all p<0·001). There was little difference by sex except in 2013, when mean scores were higher in male than in female prisoners (43·6 [12·2] vs 41·5 [11·8], p=0·029). In all sweeps, mean scores were significantly lower among people in prison than in their peers of the same age group and sex in the most deprived quintile of the general population, except among those aged 50 years or older. InterpretationThis is the first reported study of mental wellbeing in a national prisoner population to our knowledge. Mental wellbeing among prisoners is significantly lower than in the general population, even after accounting for age, sex, and socioeconomic deprivation, and is particularly low among those on remand. These results contribute to a more holistic understanding of prisoner health and provide a baseline for monitoring changes in wellbeing in response to interventions. FundingThis work was funded through a Chief Scientist Office Clinical Academic Fellowship (CAF/17/11) held by EJT and by the Medical Research Councilgrants MC_UU_12017/13 and MC_UU_12017/15, and Chief Scientist Office grants SPHSU13 and SPHSU15. Information Services Division, NHS National Services Division Scotland employs LG and XG and provided in-kind support.