The endeavors toward sustainable transportation systems are a key concern for planners and decision-makers where increasing public transport attractiveness is essential. In this paper, a machine-learning-based predictive modeling approach is proposed for metro ridership prediction, considering the built environment around the stations; it is in the best interest of sustainable transport planning to ultimately contribute to the achievement of Sustainable Development Goals (UN-SDGs). A total of twelve parameters are considered as input features including time of day, day of the week, station, and nine types of land use density. Hence, a time-series database is used for model development and testing. Several machine learning (ML) models were evaluated for their predictive performance: ridge regression, lasso regression, elastic net, k-nearest neighbor, support vector regression, decision tree, random forest, extremely randomized trees, adaptive boosting, gradient boosting, extreme gradient boosting, and stacking ensemble learner. Bayesian optimization and grid search are combined with 10-fold cross-validation to tune the hyperparameters of each model. The performance of the developed models was validated based on the test dataset using five quantitative performance measures. The results demonstrated that, among the base learners, the decision tree showed the highest performance with an R2 of 87.4% on the test dataset. KNN and SVR were the second and third-best models among the base learners. Furthermore, the feature importance investigation explains the relative contribution of each type of land use density to the prediction of the metro ridership. The results showed that governmental land use density, educational facilities land use density, and mixed-use density are the three factors that play the most critical role in determining total ridership. The outcomes of this research could be of great help to the decision-making process for the best achievement of sustainable development goals in relation to sustainable transport and land use.