An increasing number of studies have reported the close relation of the hemoglobin glycation index (HGI) with metabolism, inflammation, and disease prognosis. However, the prognostic relationship between the HGI and patients with sepsis remains unclear. Thus, this study aimed to analyze the association between the HGI and all-cause mortality in patients with sepsis using data from the MIMIC-IV database. In this study, 2605 patients with sepsis were retrospectively analyzed. The linear regression equation was established by incorporating glycated hemoglobin (HbA1c) and fasting plasma glucose levels. Subsequently, the HGI was calculated based on the difference between the predicted and observed HbA1c levels. Furthermore, the HGI was divided into the following three groups using X-tile software: Q1 (HGI ≤ - 0.50%), Q2 (- 0.49% ≤ HGI ≤ 1.18%), and Q3 (HGI ≥ 1.19%). Kaplan-Meier survival curves were further plotted to analyze the differences in 28-day and 365-day mortality among patients with sepsis patients in these HGI groups. Multivariate corrected Cox proportional risk model and restricted cubic spline (RCS) were used. Lastly, mediation analysis was performed to assess the factors through which HGI affects sepsis prognosis. This study included 2605 patients with sepsis, and the 28-day and 365-day mortality rates were 19.7% and 38.9%, respectively. The Q3 group had the highest mortality risk at 28days (HR = 2.55, 95% CI: 1.89-3.44, p < 0.001) and 365days (HR = 1.59, 95% CI: 1.29-1.97, p < 0.001). In the fully adjusted multivariate Cox proportional hazards model, patients in the Q3 group still displayed the highest mortality rates at 28days (HR = 2.02, 95% CI: 1.45-2.80, p < 0.001) and 365days (HR = 1.28, 95% CI: 1.08-1.56, p < 0.001). The RCS analysis revealed that HGI was positively associated with adverse clinical outcomes. Finally, the mediation effect analysis demonstrated that the HGI might influence patient survival prognosis via multiple indicators related to the SOFA and SAPS II scores. There was a significant association between HGI and all-cause mortality in patients with sepsis, and patients with higher HGI values had a higher risk of death. Therefore, HGI can be used as a potential indicator to assess the prognostic risk of death in patients with sepsis.