Recent research has shown that people who gamble are more likely to have suicidal thoughts and attempts compared to the general population. Despite the advancements made, no study to date has predicted suicide risk factors in people who gamble using machine learning algorithms. Therefore, current study aimed to identify the most critical predictors of suicidal ideation and suicidal attempts among people who gamble using a machine learning approach. An online survey conducted a cross-sectional analysis of 741 people who gamble (mean age: 25.9 ± 5.56). To predict the risk of suicide attempts and ideation, we employed a comprehensive set of 40 biological, psychological, social, and socio-demographic variables. The predictive models were developed using Logistic Regression, Random Forest (RF), robust eXtreme Gradient Boosting (XGBoost), and ensemble machine learning algorithms. Data analysis was performed using R-Studio software. Random Forest emerged as the top-performing algorithm for predicting suicidal ideation, with an impressive AUC of 0.934, sensitivity of 0.7514, specificity of 0.9885, PPV of 0.9473, and NPV of 0.9347. Across all models, dissociation, depression, and anxiety symptoms consistently emerged as crucial predictors of suicidal ideation. However, for suicide attempt prediction, all models exhibited weaker performance. XGBoost showed the best performance in this regard, with an AUC of 0.663, sensitivity of 0.78, specificity of 0.8990, PPV of 0.34, NPV of 0.984, and accuracy of 0.8918. Depressive symptoms and rumination severity were highlighted as the most important predictors of suicide attempts according to this model. These findings have important implications for clinical practice and public health interventions. Machine learning could help detect individuals prone to suicidal ideation and suicide attempts among people who gamble, assisting in creating tailored prevention programs to address future suicide risks more effectively.