Background: Risk stratification is an integral component of ST-segment-elevation myocardial infarction (STEMI) management practices. This study aimed to derive a machine learning (ML) model for risk stratification and identification of factors associated with in-hospital and 30-day mortality in patients with STEMI and compare it with traditional TIMI score. Methods: This was a single center prospective study wherein subjects >18 years with STEMI (n=1700) were enrolled. Patients were divided into two groups: training (n=1360) and validation dataset (n=340). Six ML algorithms (Extra Tree, Random Forest, Multiple Perceptron, CatBoost, Logistic Regression and XGBoost) were used to train and tune the ML model and to determine the predictors of worse outcomes using feature selection. Additionally, the performance of ML models both for in-hospital and 30-day outcomes was compared to that of TIMI score. Results: Of the 1700 patients, 168 (9.88%) had in-hospital mortality while 30-day mortality was reported in 210 (12.35%) subjects. In terms of in-hospital mortality, Random Forest ML model (sensitivity: 80%; specificity: 74%; AUC: 80.83%) outperformed the TIMI score (sensitivity: 70%; specificity: 64%; AUC:70.7%). Similarly, Random Forest ML model (sensitivity: 81.63%; specificity: 78.35%; AUC: 78.29%) had better performance as compared to TIMI score (sensitivity: 63.26%; specificity: 63.91%; AUC: 63.59%) for 30-day mortality. Key predictors for worse outcomes at 30-days included mitral regurgitation on presentation, smoking, cardiogenic shock, diabetes, ventricular septal rupture, Killip class, age, female gender, low blood pressure and low ejection fraction. Conclusions: ML model outperformed the traditional regression based TIMI score as a risk stratification tool in patients with STEMI.