BackgroundDiabetes has been associated with increased COVID-19-related mortality, but the association between modifiable risk factors, including hyperglycaemia and obesity, and COVID-19-related mortality among people with diabetes is unclear. We assessed associations between risk factors and COVID-19-related mortality in people with type 1 and type 2 diabetes.MethodsWe did a population-based cohort study of people with diagnosed diabetes who were registered with a general practice in England. National population data on people with type 1 and type 2 diabetes collated by the National Diabetes Audit were linked to mortality records collated by the Office for National Statistics from Jan 2, 2017, to May 11, 2020. We identified the weekly number of deaths in people with type 1 and type 2 diabetes during the first 19 weeks of 2020 and calculated the percentage change from the mean number of deaths for the corresponding weeks in 2017, 2018, and 2019. The associations between risk factors (including sex, age, ethnicity, socioeconomic deprivation, HbA1c, renal impairment [from estimated glomerular filtration rate (eGFR)], BMI, tobacco smoking status, and cardiovascular comorbidities) and COVID-19-related mortality (defined as International Classification of Diseases, version 10, code U07.1 or U07.2 as a primary or secondary cause of death) between Feb 16 and May 11, 2020, were investigated by use of Cox proportional hazards models.FindingsWeekly death registrations in the first 19 weeks of 2020 exceeded the corresponding 3-year weekly averages for 2017–19 by 672 (50·9%) in people with type 1 diabetes and 16 071 (64·3%) in people with type 2 diabetes. Between Feb 16 and May 11, 2020, among 264 390 people with type 1 diabetes and 2 874 020 people with type 2 diabetes, 1604 people with type 1 diabetes and 36 291 people with type 2 diabetes died from all causes. Of these total deaths, 464 in people with type 1 diabetes and 10 525 in people with type 2 diabetes were defined as COVID-19 related, of which 289 (62·3%) and 5833 (55·4%), respectively, occurred in people with a history of cardiovascular disease or with renal impairment (eGFR <60 mL/min per 1·73 m2). Male sex, older age, renal impairment, non-white ethnicity, socioeconomic deprivation, and previous stroke and heart failure were associated with increased COVID-19-related mortality in both type 1 and type 2 diabetes. Compared with people with an HbA1c of 48–53 mmol/mol (6·5–7·0%), people with an HbA1c of 86 mmol/mol (10·0%) or higher had increased COVID-19-related mortality (hazard ratio [HR] 2·23 [95% CI 1·50–3·30, p<0·0001] in type 1 diabetes and 1·61 [1·47–1·77, p<0·0001] in type 2 diabetes). In addition, in people with type 2 diabetes, COVID-19-related mortality was significantly higher in those with an HbA1c of 59 mmol/mol (7·6%) or higher than in those with an HbA1c of 48–53 mmol/mol (HR 1·22 [95% CI 1·15–1·30, p<0·0001] for 59–74 mmol/mol [7·6–8·9%] and 1·36 [1·24–1·50, p<0·0001] for 75–85 mmol/mol [9·0–9·9%]). The association between BMI and COVID-19-related mortality was U-shaped: in type 1 diabetes, compared with a BMI of 25·0–29·9 kg/m2, a BMI of less than 20·0 kg/m2 had an HR of 2·45 (95% CI 1·60–3·75, p<0·0001) and a BMI of 40·0 kg/m2 or higher had an HR of 2·33 (1·53–3·56, p<0·0001); the corresponding HRs for type 2 diabetes were 2·33 (2·11–2·56, p<0·0001) and 1·60 (1·47–1·75, p<0·0001).InterpretationDeaths in people with type 1 and type 2 diabetes rose sharply during the initial COVID-19 pandemic in England. Increased COVID-19-related mortality was associated not only with cardiovascular and renal complications of diabetes but, independently, also with glycaemic control and BMI.FundingNone.