BackgroundEvidence on associations between COVID-19 illness and mental health is mixed. We aimed to examine whether COVID-19 is associated with deterioration in mental health while considering pre-pandemic mental health, time since infection, subgroup differences, and confirmation of infection via self-reported test and serology data.MethodsWe obtained data from 11 UK longitudinal studies with repeated measures of mental health (psychological distress, depression, anxiety, and life satisfaction; mental health scales were standardised within each study across time) and COVID-19 status between April, 2020, and April, 2021. We included participants with information available on at least one mental health outcome measure and self-reported COVID-19 status (suspected or test-confirmed) during the pandemic, and a subset with serology-confirmed COVID-19. Furthermore, only participants who had available data on a minimum set of covariates, including age, sex, and pre-pandemic mental health were included. We investigated associations between having ever had COVID-19 and mental health outcomes using generalised estimating equations. We examined whether associations varied by age, sex, ethnicity, education, and pre-pandemic mental health, whether the strength of the association varied according to time since infection, and whether associations differed between self-reported versus confirmed (by test or serology) infection.FindingsBetween 21 Dec, 2021, and July 11, 2022, we analysed data from 54 442 participants (ranging from a minimum age of 16 years in one study to a maximum category of 90 years and older in another; including 33 200 [61·0%] women and 21 242 [39·0%] men) from 11 longitudinal UK studies. Of 40 819 participants with available ethnicity data, 36 802 (90·2%) were White. Pooled estimates of standardised differences in outcomes suggested associations between COVID-19 and subsequent psychological distress (0·10 [95% CI 0·06 to 0·13], I2=42·8%), depression (0·08 [0·05 to 0·10], I2=20·8%), anxiety (0·08 [0·05 to 0·10], I2=0·0%), and lower life satisfaction (–0·06 [–0·08 to –0·04], I2=29·2%). We found no evidence of interactions between COVID-19 and sex, education, ethnicity, or pre-pandemic mental health. Associations did not vary substantially between time since infection of less than 4 weeks, 4–12 weeks, and more than 12 weeks, and were present in all age groups, with some evidence of stronger effects in those aged 50 years and older. Participants who self-reported COVID-19 but had negative serology had worse mental health outcomes for all measures than those without COVID-19 based on serology and self-report. Participants who had positive serology but did not self-report COVID-19 did not show association with mental health outcomes.InterpretationSelf-reporting COVID-19 was longitudinally associated with deterioration in mental health and life satisfaction. Our findings emphasise the need for greater post-infection mental health service provision, given the substantial prevalence of COVID-19 in the UK and worldwide.FundingUK Medical Research Council and UK National Institute for Health and Care Research.