Natural gas is an important clean energy source that is mainly transported through pipelines. The ball valve is a crucial piece of control equipment for the pipeline transportation system for natural gas, and the failure of internal leakage of the ball valve will seriously affect the natural gas transmission and increase the risk of sudden safety accidents. In response to the problems of the limitations of a single machine learning model in the traditional ball valve internal leakage rate prediction methods and failure to qualitatively analyze unilateral and bilateral internal leakage recognition of ball valve, a study of ball valve internal leakage detection based on Stacking ensemble learning is proposed. A total of 15 time and frequency domain feature parameters were obtained by feature extraction of 125 and 96 sets of raw acoustic emission signals from the ball valve; the parameters of a single machine learning model were adjusted by Bayesian optimization grid search. An internal leakage rate prediction model and an internal leakage recognition model are constructed, and the proposed model is compared and analyzed with a single model through a field ball valve internal leakage test. The results indicate that the Stacking ensemble learning model outperforms each single machine learning model in terms of SMAPE (17.2583), RMSE (1.1009), and MAE (0.9375) for internal leakage rate prediction. The Stacking ensemble learning model outperformed the single machine learning model in terms of accuracy (1.0000), recall (1.0000), precision (1.0000), FAR(0), and F1-score (1.0000) for internal leakage recognition. Stacking ensemble learning significantly enhances the model’s ability to detect internal ball valve leaks.