The identification of efficient predictors for short-term mortality among patients with myocardial infarction (MI) in coronary care units (CCU) remains a challenge. This study seeks to investigate the potential of machine learning (ML) to improve risk prediction and develop a predictive model specifically tailored for 30-day mortality in critical MI patients. This study focused on MI patients extracted from the Medical Information Mart for Intensive Care-IV database. The patient cohort was randomly stratified into derivation (n = 1,389, 70%) and validation (n = 595, 30%) groups. Independent risk factors were identified through eXtreme Gradient Boosting (XGBoost) and random decision forest (RDF) methodologies. Subsequently, multivariate logistic regression analysis was employed to construct predictive models. The discrimination, calibration and clinical utility were assessed utilizing metrics such as receiver operating characteristic (ROC) curve, calibration plot and decision curve analysis (DCA). A total of 1,984 patients were identified (mean [SD] age, 69.4 [13.0] years; 659 [33.2%] female). The predictive performance of the XGBoost and RDF-based models demonstrated similar efficacy. Subsequently, a 30-day mortality prediction algorithm was developed using the same selected variables, and a regression model was visually represented through a nomogram. In the validation group, the nomogram (Area Under the Curve [AUC]: 0.835, 95% Confidence Interval [CI]: [0.774-0.897]) exhibited superior discriminative capability for 30-day mortality compared to the Sequential Organ Failure Assessment (SOFA) score [AUC: 0.735, 95% CI: (0.662-0.809)]. The nomogram (Accuracy: 0.914) and the SOFA score (Accuracy: 0.913) demonstrated satisfactory calibration. DCA indicated that the nomogram outperformed the SOFA score, providing a net benefit in predicting mortality. The ML-based predictive model demonstrated significant efficacy in forecasting 30-day mortality among MI patients admitted to the CCU. The prognostic factors identified were age, blood urea nitrogen, heart rate, pulse oximetry-derived oxygen saturation, bicarbonate, and metoprolol use. This model serves as a valuable decision-making tool for clinicians.