Pavement temperature is crucial for assessing asphalt pavement's performance and structural integrity due to its viscoelastic behavior. Currently, asphalt temperature prediction includes analytical, numerical, and statistical methods and relies on field investigation with intensive labor and time to hinder routine practice. Machine learning (ML) offers a promising solution for reliable and accurate real-time predictions by considering various dynamic environmental factors. This research employs four ensemble ML algorithms: eXtreme Gradient Boosting (XGB), Light Gradient Boosting Machine (LGBM), Random Forest (RF), and Adaptive Boosting (AdaBoost) to predict pavement temperature at different depths. XGB consistently outperformed other ensemble models, boasting the highest average R2 value (97.92%) and lower MAE and RMSE than LGBM, RF, and AdaBoost. XGB also significantly outperformed other commonly used models (linear regression, SVR, ANN, LSTM, and GRU) with an average reduction in errors of 35.29%, 63.75%, 42.75%, and an increase in R2 by 4.39% for MAE, MSE, RMSE, and R2, respectively. The Shapley additive explanation (SHAP) was applied to interpret the underlying influencing factors and their interactions, and revealed atmospheric temperature as the most impactful feature, contributing over 40.58% among the significant features.Furthermore, the predictive performance of XGB was enhanced by incorporating Principal Component Analysis to reduce computational consumption with average reductions of 8.98%, 16.59%, 9.01%, and 7.89% in MAE, MSE, MAPE, and RMSE. XGB with PCA emerges as the most effective and efficient model for predicting pavement temperatures at various depths to facilitate timely decision-making for preventive maintenance and rehabilitation and prevent future catastrophic failures.