Heart disease remains a major global health challenge due to its increasing prevalence, highlighting the need for accurate and reliable early diagnostic systems. This study aims to analyze and compare the performance of Random Forest (RF) and XGBoost algorithms for heart disease classification, and to identify the most suitable model for data-driven clinical decision support. Addressing a research gap in ensemble learning studies, this research conducts a comprehensive comparative evaluation using the UCI Heart Disease Dataset. The proposed methodology includes data preprocessing, feature encoding, normalization, class imbalance handling using the Synthetic Minority Oversampling Technique (SMOTE), and hyperparameter optimization based on RandomizedSearchCV. Model performance is evaluated using accuracy, precision, recall, F1-score, ROC-AUC, and Matthews Correlation Coefficient (MCC), supported by Feature Importance analysis. The results demonstrate that both ensemble models achieve strong predictive performance, with consistently high F1-scores above 0.88. XGBoost exhibits superior overall performance, achieving the highest F1-score of 0.8995 and Precision of 0.8785, making it more effective in minimizing False Positive predictions. In contrast, Random Forest shows superior sensitivity, with the highest Recall of 0.9510 and ROC-AUC of 0.9582, along with better cross-validation stability. These findings indicate that the selection of heart disease classification algorithms should be aligned with specific clinical objectives, and the results of this study are expected to contribute to the development of effective machine learning–based clinical decision support systems.