Background Sepsis is a complex systemic inflammatory response syndrome triggered by infection with high morbidity and mortality. The systemic immune-inflammation index (SII) is a biomarker of inflammation and immune status. This study investigated the relationship between the SII trajectory and in-hospital mortality in patients with sepsis. Methods This retrospective study included 1015 adults who were admitted via the emergency department of the First Hospital of Jilin University with a first episode of sepsis between June 2018 and February 2025. Latent-class mixed models (LCMM) were used to identify SII trajectory subgroups, and Cox regression was used to analyze the relationship between subgroups and in-hospital mortality. An eXtreme Gradient Boosting (XGBoost) machine learning model was used to quantify the effect of each variable on the risk of in-hospital mortality. Restricted cubic spline (RCS) analysis assessed the nonlinear relationship between SII and in-hospital mortality. Results LCMM analysis identified five SII trajectory subgroups. Cox regression analysis showed that Class 1 (the group with continuous increase in SII from a low to medium level), Class 3 (the group with a stable decline in SII from a high level), Class 4 (the group with a stable high SII level) and Class 5 (the group with a stable medium SII level) all had higher risk of in-hospital mortality than Class 2 (the group with a stable medium-high SII level). Class 1 and Class 4 had the highest risk of in-hospital mortality (hazard ratio [HR] 15.14 and 6.31, respectively). The XGBoost model confirmed that the SII trajectories were independent predictors of in-hospital mortality. The RCS analysis revealed a U-shaped relationship between the SII within 24 hours after admission and in-hospital mortality, with both low and high SII levels associated with higher in-hospital mortality. Conclusions In patients with sepsis, the risk of in-hospital mortality differs according to the SII within 24 hours of admission and the SII trajectory. The risk of in-hospital mortality was greatest in patients whose SII increased continuously and those whose SII stabilized at a high level, and was lowest in patients with an SII stabilized at a medium-high level. The SII within 24 hours after admission had a U-shaped relationship with in-hospital mortality.