Station-level ridership is an important indicator for understanding the relationship between land use and rail transit, which is crucial for building more sustainable urban mobility systems. However, the nonlinear effects of the built environment on metro ridership, particularly concerning temporal heterogeneity, have not been adequately explained. To address this gap, this study proposes a versatile methodology that employs the eXtreme gradient boosting (XGBoost) tree to analyze the effects of factors on station-level ridership variations and compares these results with those of a multiple regression model. In contrast to conventional feature interpretation methods, this study utilized Shapley additive explanations (SHAP) to detail the nonlinear effects of each factor on station-level ridership across temporal dimensions (weekdays and weekends). Using Shanghai as a case study, the findings confirmed the presence of complex nonlinear and threshold effects of land-use, transportation, and station-type factors on station-level ridership in the association. The factor “Commercial POI” represents the most significant influence on ridership changes in both the weekday and weekend models; “Public Facility Station” plays a role in increasing passenger flow in the weekend model, but it shows the opposite effect on the change in ridership in the weekday model. This study highlights the importance of explainable machine learning methods for comprehending the nonlinear influences of various factors on station-level ridership.