Type 2 diabetes and prediabetes are risk factors for heart failure and adverse heart failure outcomes. The Dapagliflozin Evaluation to Improve the Lives of Patients with Preserved Ejection Fraction Heart Failure (DELIVER) trial showed that dapagliflozin was associated with a reduction in the primary outcome of worsening heart failure or cardiovascular mortality in patients with heart failure with mildly reduced or preserved ejection fraction. We aimed to assess the efficacy and safety of oral dapagliflozin in these patients by their baseline glycaemia categories. DELIVER was an international, multicentre, double-blind, randomised, placebo-controlled trial done in 350 health-care centres and hospitals across 20 countries. Patients aged 40 years or older with New York Heart Association class II-IV, left ventricular ejection fraction of more than 40%, elevated natriuretic peptides (N-terminal pro B-type natriuretic peptide ≥300 pg/mL or ≥600 pg/mL for patients in atrial fibrillation or flutter), and evidence of structural heart disease were randomly assigned (1:1) to 10 mg dapagliflozin or placebo, administered orally, and followed up for a median of 2·3 years (IQR 1·7-2·8). The primary outcome, a composite of time from randomisation to first worsening heart failure events (defined as an unplanned hospitalisation or urgent heart failure visit requiring intravenous therapy) or cardiovascular death, in participants with type 2 diabetes (history of or identified by HbA1c ≥6·5% [48 mmol/mol] at baseline) or prediabetes (HbA1c 5·7 to <6·5% [39 mmol/mol to <48 mmol/mol] at baseline) was compared with those with normoglycaemia (HbA1c <5·7% [39 mmol/mol]). Efficacy of dapagliflozin versus placebo was assessed according to glycaemic status and based on HbA1c as a continuous measure. The full-analysis set comprised all patients who were randomly assigned to study treatment, with patients analysed according to their randomised treatment assignment, irrespective of the treatment received (ie, intention to treat). The safety analysis set comprised patients who were randomly assigned to study treatment and who took at least one dose of investigational product, with patients analysed according to the treatment actually received. This trial is registered with ClinicalTrials.gov, NCT03619213. Between Sept 1, 2018, and Jan 18, 2021, 6263 patients were randomly assigned to oral dapagliflozin (n=3131) or placebo (n=3132). Of these patients, 1175 had normoglycaemia, 1934 had prediabetes, and 3150 had type 2 diabetes and were included in the glycaemia subgroup analysis (3515 [56·2%] of 6263 patients were men and 4435 [70·9%] were White). The incidence rate of the primary outcome was 6·9 per 100 patient-years in the normoglycaemia subgroup (reference), increasing to 7·6 per 100 patient-years in the prediabetes subgroup (hazard ratio 1·09 [95% CI 0·90-1·31]) and 10·1 per 100 patient-years in the type 2 diabetes subgroup (1·46 [1·24-1·73]; p<0·0001 for trend). Dapagliflozin reduced the risk of the primary outcome versus placebo in each subgroup (hazard ratio 0·77 [95% CI 0·57-1·04], log-rank p=0·088, for patients with normoglycaemia, 0·87 [0·69-1·08], log-rank p=0·21, for patients with prediabetes, and 0·81 [0·69-0·95], log-rank p=0·0077, for patients with type 2 diabetes; pinteraction=0·82) and across the continuous HbA1c range (pinteraction=0·85). Volume-related or renal serious adverse events or adverse events leading to discontinuation of the study drug, hypoglycaemia, and amputations were not differentially affected by treatment in any of the glycaemia categories. In patients with heart failure with mildly reduced or preserved ejection fraction, oral dapagliflozin improved heart failure outcomes to a similar extent in three glycaemia subgroups: normoglycaemia, prediabetes, and type 2 diabetes. Moreover, the heart failure benefits of dapagliflozin seem to be consistent across a continuous glycaemic range. AstraZeneca.