Heart disease (HD) is the primary cause of death globally, requiring more accurate, affordable diagnostic technologies. Traditional HD diagnostic methods are adequate but expensive and limited, creating a need for creative alternatives. Machine learning (ML) is one of the many sophisticated technologies healthcare systems use to predict diseases. This work aims to enhance the accuracy and efficiency of HD diagnosis by developing a stacked ensemble classifier that combines predictions from different ML classifiers and uses chi-square feature selection to prioritize significant features. Combining predictions from three basic ML classifiers—decision trees (DT), support vector machines (SVM), and multilayer perceptron (MLP)—the paper creates a stacked ensemble classifier. To raise diagnostic accuracy, this stacked ensemble classifier maximizes the strengths of base classifiers and reduces their errors. Furthermore, applying the chi-square feature selection approach, the study finds five important features for training the classifiers on the Cleveland dataset with thirteen (13) features. Selecting only important features through feature selection minimizes dimensionality, simplifies the classifier, and improves computational performance. This also reduces overfitting, increases generalizability, and speeds up diagnosis, making it more viable for real-time clinical applications. Before and following the feature selection procedure, the ensemble classifier performance is assessed against the base classifiers concerning the accuracy, recall, precision, and f1-score. These metrics are chosen for their ability to validate the effectiveness of the proposed diagnostic tool. With an accuracy of 85.5%, the stacked ensemble classifier exceeded base classifiers before feature selection. After feature selection, the stacked ensemble classifier’s accuracy improved to 90.8%. These results underline the proposed method as an inexpensive and more efficient diagnostic tool for HD as compared to current methods, enabling earlier HD detection and lowering healthcare costs. In conclusion, this creative method could alter healthcare systems by providing a highly accurate and affordable diagnostic tool for clinical use.