The Sustainable Development Goals (SDGs) are essential measure for preserving the balance between human well-being and natural ecosystems. The benefit of preserving ecosystems health play a crucial role in promoting the SDGs by providing stable ecosystem services (ESs). However, the ecological health of mountainous cities is vulnerable, with relative low ecological resilience. To investigate the conflict between ecosystems and sustainable development, this study takes the Chengdu-Chongqing Urban Agglomeration as the study area. The major tasks and results in this study include: (1) using the entropy weighting method and the InVEST model, we combined remote sensing, geographic, and statistical data to quantify three types of SDGs (economic, social, environmental) and four ESs (water yield, soil conservation, habitat quality, carbon storage), and establish a localized sustainable development assessment framework that is applicable to the Chengdu-Chongqing Urban Agglomeration. The results show that from 2014 to 2020, the three types of SDGs exhibited an overall upward trend, with the lowest values occurring in 2016. The gap between different counties has narrowed, but significant regional differences still remain, indicating an unbalanced development status quo. Among the 142 counties, water yield and soil conservation values show a consistent downward trend but occupies significant interannual variations, while habitat quality and carbon storage values increases consistently each year. (2) using Spearman's nonparametric correlation analysis and multiscale geographically weighted regression model to explore the temporal variation and spatial heterogeneity of correlations between county ESs and SDGs. The results showed significant heterogeneity in the spatial trade-offs and synergies between ESs and SDGs, with two pairs of synergies weakening, seven pairs of trade-offs increasing, and the strongest negative correlation between Economic Sustainable Development Goals and habitat quality. (3) we applied the self-organizing mapping neural networks to analyze the spatial clustering characteristics of ESs-SDGs. Based on the spatial clustering effects, we divides the Chengdu-Chongqing Urban Agglomeration into four zones, and different zones have different levels of ESs and SDGs. The targeted strategies should be adopted according to local conditions. This work is of great practical importance in maintaining the stability and sustainable development of the Chengdu-Chongqing Urban Agglomeration ecosystem and provides a scientific reference for the optimal regulation of mountainous cities.