SummaryBackgroundThe COVID-19 pandemic has adversely affected population mental health. We aimed to assess temporal trends in primary care-recorded common mental illness, episodes of self-harm, psychotropic medication prescribing, and general practitioner (GP) referrals to mental health services during the COVID-19 emergency in the UK.MethodsWe did a population-based cohort study using primary care electronic health records from general practices registered on the UK Clinical Practice Research Datalink (CPRD). We included patient records from Jan 1, 2010, to Sept 10, 2020, to establish long-term trends and patterns of seasonality, but focused primarily on the period January, 2019–September, 2020. We extracted data on clinical codes entered into patient records to estimate the incidence of depression and anxiety disorders, self-harm, prescriptions for antidepressants and benzodiazepines, and GP referrals to mental health services, and assessed event rates of all psychotropic prescriptions and self-harm. We used mean-dispersion negative binomial regression models to predict expected monthly incidence and overall event rates, which were then compared with observed rates to assess the percentage reduction in incidence and event rates after March, 2020. We also stratified analyses by sex, age group, and practice-level Index of Multiple Deprivation quintiles.FindingsWe identified 14 210 507 patients from 1697 UK general practices registered in the CPRD databases. In April, 2020, compared with expected rates, the incidence of primary care-recorded depression had reduced by 43·0% (95% CI 38·3–47·4), anxiety disorders by 47·8% (44·3–51·2), and first antidepressant prescribing by 36·4% (33·9–38·8) in English general practices. Reductions in first diagnoses of depression and anxiety disorders were largest for adults of working age (18–44 and 45–64 years) and for patients registered at practices in more deprived areas. The incidence of self-harm was 37·6% (34·8–40·3%) lower than expected in April, 2020, and the reduction was greatest for women and individuals aged younger than 45 years. By September, 2020, rates of incident depression, anxiety disorder, and self-harm were similar to expected levels. In Northern Ireland, Scotland, and Wales, rates of incident depression and anxiety disorder remained around a third lower than expected to September, 2020. In April, 2020, the rate of referral to mental health services was less than a quarter of the expected rate for the time of year (75·3% reduction [74·0–76·4]).InterpretationConsequences of the considerable reductions in primary care-recorded mental illness and self-harm could include more patients subsequently presenting with greater severity of mental illness and increasing incidence of non-fatal self-harm and suicide. Addressing the effects of future lockdowns and longer-term impacts of economic instability on mental health should be prioritised.FundingNational Institute for Health Research and Medical Research Council.