Serious concerns have been raised about the negative effects of the COVID-19 pandemic on population psychological well-being. However, limited data exist on the long-term effects of the pandemic on incident psychiatric morbidities among individuals with varying exposure to the pandemic. Leveraging prospective data from the community-based UK Biobank cohort, we included 308,400 participants free of diagnosis of anxiety or depression, as well as 213,757 participants free of anxiolytics or antidepressants prescriptions, to explore the trends in incident diagnoses and drug prescriptions for anxiety and depression from 16 March 2020 to 31 August 2021, compared to the pre-pandemic period (i.e., 1 January 2017 to 31 December 2019) and across populations with different exposure statuses (i.e., not tested for COVID-19, tested negative and tested positive). The age- and sex-standardized incidence ratios (SIRs) were calculated by month which indicated an increase in incident diagnoses of anxiety or depression among individuals who were tested for COVID-19 (tested negative: SIR 3.05 [95% confidence interval 2.88–3.22]; tested positive: 2.03 [1.76–2.34]), especially during the first six months of the pandemic (i.e., March-September 2020). Similar increases were also observed for incident prescriptions of anxiolytics or antidepressants (tested negative: 1.56 [1.47–1.67]; tested positive: 1.41 [1.22–1.62]). In contrast, individuals not tested for COVID-19 had consistently lower incidence rates of both diagnoses of anxiety or depression (0.70 [0.67–0.72]) and prescriptions of respective psychotropic medications (0.70 [0.68–0.72]) during the pandemic period. These data suggest a distinct rise in health care needs for anxiety and depression among individuals tested for COVID-19, regardless of the test result, in contrast to a reduction in health care consumption for these disorders among individuals not tested for and, presumably, not directly exposed to the disease.