Abstract Background The stress hyperglycemia ratio (SHR) was created to reduce the impact of long-term chronic glycemic factors on stress hyperglycemia, which is considered a reliable biomarker for adverse outcomes in intensive care patients. However, the relationship between SHR and the outcomes for critically ill patients with heart failure (HF) remains unclear. Methods This retrospective cohort study analyzed 1,438 critically ill patients with HF from the Medical Information Mart for Intensive Care IV (MIMIC-IV, v3.1) database (2008–2022). Patients were followed from ICU admission to death or 365days. SHR was calculated as admission glucose (mmol/L) / [1.59 × HbA1c (%) − 2.59]. Multivariable Cox regression with four adjustment levels evaluated the association between SHR and mortality. Restricted cubic splines assessed nonlinear relationships, and Kaplan-Meier methodology with log-rank tests analyzed survival patterns. Results In the cohort, each 1-unit increase in SHR was associated with a 40% higher 30-day mortality risk (HR 1.40, 95% CI 1.20–1.63, P < 0.001) and a 31% higher 90-day mortality risk (HR 1.31, 95% CI 1.14–1.51, P < 0.001). Patient survival rates decreased significantly with higher SHR tertiles (P < 0.001), and restricted cubic spline analysis confirmed a linear relationship. Subgroup analyses confirmed the robustness of these links. Conclusions Elevated SHR is significantly associated with increased mortality in critically ill patients with HF, supporting its role as a valuable biomarker for risk stratification in this high-risk population. Graphical abstract The Association Between SHR and Mortality in Critically Ill Patients with HF.