To investigate the association between sodium-glucose cotransporter-2 (SGLT-2) inhibitor use and risk of all cause mortality among patients with heart failure with reduced ejection fraction. Linked database study. National registers in Denmark, July 2020 to June 2023. Patients with heart failure, aged ≥45 years, with left ventricular ejection fraction ≤40%. The primary outcome was all cause mortality comparing initiation and continued treatment with SGLT-2 inhibitors versus continued treatment with other standard-of-care heart failure drugs and non-use of SGLT-2 inhibitors; secondary outcomes were the composite of cardiovascular mortality or admission to hospital with heart failure and its individual components. Hazard ratios were estimated using Cox regression adjusted using inverse probability of treatment weighting based on propensity scores. The study included 6776 patients who started SGLT-2 inhibitors (79% dapagliflozin; 21% empagliflozin) and 14 686 patients who remained on other standard-of-care heart failure drugs and did not use SGLT-2 inhibitors. Most SGLT-2 inhibitor users were male (70%), the mean age was 71.2 (standard deviation 10.6) years, and 20% had type 2 diabetes. During follow-up, 374 deaths occurred among SGLT-2 inhibitor users (incidence rate 5.8 per 100 person years) and 1602 among non-users (8.5 per 100 person years). The weighted hazard ratio for all cause mortality was 0.75 (95% confidence interval 0.66 to 0.85); the weighted incidence rate difference was -1.6 (95% confidence interval -2.5 to -0.8) per 100 person years. Secondary outcomes showed a weighted hazard ratio of 0.94 (0.85 to 1.04) for cardiovascular mortality or hospital admission with heart failure, 0.77 (0.64 to 0.92) for cardiovascular mortality, and 1.03 (0.92 to 1.15) for hospital admission with heart failure. The weighted hazard ratios for all cause mortality were consistent in patients with and without diabetes (0.73 (0.58 to 0.91) and 0.73 (0.63 to 0.85); P=0.99). In this large database study among patients with heart failure with reduced ejection fraction, SGLT-2 inhibitor use was associated with a 25% lower risk of all cause mortality, supporting their effectiveness in routine clinical practice.