Although studies have suggested a high risk of suicide in people with eating disorders, most studies have focused on suicidal ideation and attempts. There is little research on the characteristics of people with eating disorders who died by suicide, nor investigation of trends over time. We aimed to compare the characteristics of patients with eating disorders who died by suicide versus patients with other mental health diagnoses who died by suicide in England and to examine the trends in rates. In this national retrospective cohort study, data on all people (aged ≥10 years) who died by suicide in England, UK, between Jan 1, 1997, and Dec 31, 2021, while under the care (within the previous 12 months) of mental health services were obtained from the National Confidential Inquiry into Suicide and Safety in Mental Health (NCISH), in which clinical information is collected via a questionnaire completed by the mental health professional responsible for the patient's care. Incidence of suicide in, and demographic, clinical, and treatment characteristics of, patients with a diagnosis of eating disorder (as recorded by the treating clinician) who died by suicide were compared with patients with other mental health diagnoses who died by suicide within the same timeframe using univariable logistic regression analysis. People with related lived experience were involved in the study design, implementation, interpretation, and writing of the manuscript. Of 119 446 people for whom NCISH were notified of dying by suicide in England, 30 795 were under the recent care of mental health services, of whom 30 246 had known diagnoses and were included in analyses. Of these individuals, 10 373 (34%) were female and 19 873 (66%) were male; 2236 (8%) were of minority ethnicity; 382 (1%) had a diagnosis of eating disorder and 29 864 (99%) had another mental health diagnosis. Compared with patients with other mental health diagnoses who died by suicide, patients with eating disorders were younger (median age 33 years [range 15-90] vs 45 years [10-100]), more often female (343 [90%] female and 39 [10%] male in the eating disorders group; 10 030 [34%] female and 19 834 [66%] male in the other diagnoses group), and less likely to have evidence of conventional risk factors for suicide such as living alone (odds ratio [OR] 0·68, 95% CI 0·55-0·84). 22 (6%) of 382 were from a minority ethnic group. Patients with an eating disorder were characterised by a greater clinical complexity (eg, self-harm [OR 2·31, 95% CI 1·78-3·00], comorbidity [9·79, 6·81-14·1], and longer duration of illness [1·95, 1·56-2·43]), and were more likely to have died following overdoses (2·00, 1·62-2·45) than patients with other diagnoses. Childhood abuse (52 [37%] of 140) and domestic violence (18 [20%] of 91) were common in patients with eating disorders. Similar to patients with other diagnoses, most (244 [75%] of 326) of those with eating disorders who died by suicide were rated as low risk by clinicians at last contact. The number of suicide deaths in patients with eating disorders rose between 1997 and 2021 (incidence rate ratio [IRR] 1·03, 95% CI 1·02-1·05; p<0·0001), but rates fell when accounting for the greater number of patients entering mental health services (IRR 0·97, 0·95-1·00; p=0·033). This study was focused on people who sought help from mental health services. It did not consider subtypes of eating disorders or include a control group, but it does highlight possible areas for intervention. The comprehensive provision of evidence-based treatment for eating disorders and underlying conditions to address the clinical complexity in these patients might help to reduce suicide. Recognising limitations in clinical risk assessment, addressing early life experiences and current adversities, and appropriate prescribing might also be of benefit. Suicide prevention must remain a priority for eating disorder services and mental health care more widely. The Healthcare Quality Improvement Partnership.