Summary Background Although diabetes has been associated with COVID-19-related mortality, the absolute and relative risks for type 1 and type 2 diabetes are unknown. We assessed the independent effects of diabetes status, by type, on in-hospital death in England in patients with COVID-19 during the period from March 1 to May 11, 2020. Methods We did a whole-population study assessing risks of in-hospital death with COVID-19 between March 1 and May 11, 2020. We included all individuals registered with a general practice in England who were alive on Feb 16, 2020. We used multivariable logistic regression to examine the effect of diabetes status, by type, on in-hospital death with COVID-19, adjusting for demographic factors and cardiovascular comorbidities. Because of the absence of data on total numbers of people infected with COVID-19 during the observation period, we calculated mortality rates for the population as a whole, rather than the population who were infected. Findings Of the 61 414 470 individuals who were alive and registered with a general practice on Feb 16, 2020, 263 830 (0·4%) had a recorded diagnosis of type 1 diabetes, 2 864 670 (4·7%) had a diagnosis of type 2 diabetes, 41 750 (0·1%) had other types of diabetes, and 58 244 220 (94·8%) had no diabetes. 23 698 in-hospital COVID-19-related deaths occurred during the study period. A third occurred in people with diabetes: 7434 (31·4%) in people with type 2 diabetes, 364 (1·5%) in those with type 1 diabetes, and 69 (0·3%) in people with other types of diabetes. Unadjusted mortality rates per 100 000 people over the 72-day period were 27 (95% CI 27–28) for those without diabetes, 138 (124–153) for those with type 1 diabetes, and 260 (254–265) for those with type 2 diabetes. Adjusted for age, sex, deprivation, ethnicity, and geographical region, compared with people without diabetes, the odds ratios (ORs) for in-hospital COVID-19-related death were 3·51 (95% CI 3·16–3·90) in people with type 1 diabetes and 2·03 (1·97–2·09) in people with type 2 diabetes. These effects were attenuated to ORs of 2·86 (2·58–3·18) for type 1 diabetes and 1·80 (1·75–1·86) for type 2 diabetes when also adjusted for previous hospital admissions with coronary heart disease, cerebrovascular disease, or heart failure. Interpretation The results of this nationwide analysis in England show that type 1 and type 2 diabetes were both independently associated with a significant increased odds of in-hospital death with COVID-19. Funding None.