Background Informal care is increasingly common in ageing populations. However, the impact of caring responsibilities on carers’ mental health remains unclear. We used data from the HealthWise Wales (HWW) cohort to examine the impact of caregiving on the mental health of carers. Methods HWW collects demographic, lifestyle, and opinion data, which are linked to routine health-care records, from individuals aged 16 years or older who live in Wales, UK (n=21 779). Mental health was assessed by use of the short Mental Health Inventory (MHI-5) and self-reported diagnosis of mental health conditions. Data on diagnosis of common mental disorders (CMD), including depression and anxiety, were obtained from linked health-care records. Level of caring responsibilities and its impact on the individual's work were self-reported. We estimated associations between caring responsibilities and CMD using logistic regression adjusting for gender, age, and deprivation. HWW received ethics approval from Wales Research Ethics Committee (REC) 3 on March 16, 2015 (reference 15/WA/0076). All participants gave informed consent digitally as a pre-requisite for registration online. Findings The cohort included 3682 carers; 2791 (76%) were female, 2833 (77%) were aged 45 years or older, and 1900 (53%) lived in more deprived areas. The cohort of non-carers included 10 023 people; 7107 (71%) were female, 6030 (60%) were aged 45 years or older, and 4814 (49%) lived in more deprived areas. Of those identifying as carers, 1271 (35%) of 3607 with linked health records self-reported a CMD and 1331 (44%) of 3057 with linked health records had a diagnosis of a CMD versus 3029 (31%) and 2992 (36%) of non-carers, respectively. There was 80% agreement between self-report and recorded diagnosis of a CMD in health-care records. Compared with non-carers, carers were 1·3 times more likely to have an MHI5 score indicating current CMD (odds ratio [OR] 1·28, 95% CI 1·17–1·40; p<0·0001). Participants who had previously given up work to provide care were also more likely to have an MHI5 score indicative of a CMD (1·67, 1·47–1·88; p<0·0001). Being a carer was further linked to the likelihood of self-reported diagnosis of a CMD (1·21, 1·11–1·32; p<0·0001) and of diagnosis of a CMD from health-care records (1·32, 1·21–1·44; p<0·0001), even after adjusting for sociodemographic factors. Interpretation This study suggests that caring is linked to poor mental health, emphasising the potential burden of caring responsibilities on the carers’ mental health across the population. While acknowledging the cross-sectional nature of these data, these findings highlight the need to develop and test interventions that can support informal carers to protect their mental health. Funding Health and Care Research Wales.