Background:Patients with myocardial infarction (MI) in intensive care units (ICU) are at high risk of death. Whether treatment with ondansetron (OND) at an early stage plays a protective role in critically ill patients with MI and its underlying mechanism remains unclear.Methods:A total of 4486 patients with MI were enrolled in the study cohort from the Medical Information Mart for Intensive Care IV (MIMIC-IV) database and divided into OND-medication groups or not. Propensity score matching (PSM) and regression analysis were performed to investigate the effect of OND on patients, accompanied by sensitivity analysis to evaluate the robustness of the results. Integrated with causal mediation analysis (CMA), we investigated the potential causal pathway mediated by the palate-to-lymphocyte ratio (PLR) between early OND treatment and clinical outcomes.Results:Among patients with MI, 976 of them were treated with OND at the early stage while 3510 patients were not. The all-cause in-hospital mortality rate was significantly lower in the OND-medication group (5.6% vs 7.7%), accompanied by lower 28-day mortality (7.8% vs 11.3%) and 90-day mortality (9.2% vs 13.1%) rates. PSM analysis further confirmed the results for in-hospital mortality (5.7% vs 8.0%), 28-day mortality (7.8% vs 10.8%), and 90-day mortality (9.2% vs 12.5%). After adjusting for confounders, multivariate logistic regression analysis revealed that OND was associated with decreased in-hospital mortality (OR = 0.67, 95% CI: 0.49-0.91), and Cox regression confirmed the results for 28-day mortality and 90-day mortality with HR = 0.71 and 0.73, respectively. Most importantly, CMA demonstrated that the protective effect of OND on patients with MI was mediated by its anti-inflammatory effect through the regulation of PLR.Conclusion:Early use of OND in critically ill patients with MI may exert protective effects by reducing in-hospital mortality and 28- and 90-day mortality. The beneficial effects of OND on these patients were exerted through anti-inflammatory effects, at least in part.