Concerns have been raised that antipsychotic drug prescribing, which has been associated with increased mortality in people with dementia, might have increased during the COVID-19 pandemic due to social restrictions imposed to limit the spread of SARS-CoV-2. We used multisource, routinely collected health-care data from Wales, UK to investigate prescribing and mortality variations in people with dementia before and during the COVID-19 pandemic. In this retrospective cohort study, we used individual-level, anonymised, population-scale linked health data to identify adults aged 60 years and older with a diagnosis of dementia in Wales, UK. We used the CVD-COVID-UK initiative to access Welsh routinely collected electronic health record data from the Secure Anonymised Information Linkage (SAIL) Databank. Patients who were alive and registered with a SAIL general practice on Jan 1, 2016, and who received a dementia diagnosis before the age of 60 years and before or during the study period were included. We explored antipsychotic drug prescribing rate changes over 67 months, between Jan 1, 2016, and Aug 1, 2021, overall and stratified by age and dementia subtype. We used time-series analyses to examine all-cause and myocardial infarction and stroke mortality over the study period and identified the leading causes of death in people with dementia between Jan 1, 2020, and Aug 1, 2021. Of 3 106 690 participants in SAIL between Jan 1, 2016 and Aug 1, 2021, 57 396 people (35 148 [61·2%] women and 22 248 [38·8%] men) met inclusion criteria for this study and contributed 101 428 person-years of follow-up. Of the 57 396 people with dementia, 11 929 (20·8%) were prescribed an antipsychotic drug at any point during follow-up. Accounting for seasonality, antipsychotic drug prescribing increased during the second half of 2019 and throughout 2020. However, the absolute difference in prescribing rates was small, ranging from 1253 prescriptions per 10 000 person-months in March, 2019, to 1305 per 10 000 person-months in September, 2020. All-cause mortality and stroke mortality increased throughout 2020, while myocardial infarction mortality declined. From Jan 1, 2020, to Aug 1, 2021, 1286 (17·1%) of 7508 participants who died had COVID-19 recorded as the underlying cause of death. During the COVID-19 pandemic, antipsychotic drug prescribing in people with dementia in the UK increased slightly; however, it is unlikely that this was solely related to the pandemic and this increase was unlikely to be a major factor in the substantial increase in mortality during 2020. The long-term increase in antipsychotic drug prescribing in younger people and in those with Alzheimer's disease warrants further investigation using resources with access to more granular clinical data. Although deprescribing antipsychotic medications remains an essential aspect of dementia care, the results of this study suggest that changes in prescribing and deprescribing practices as a result of the COVID-19 pandemic are not required. British Heart Foundation (via the British Heart Foundation Data Science Centre led by Health Data Research UK), and the Scottish Neurological Research Fund.