[Objective] The spatiotemporal evolution of urban ecological security patterns under the influence of urbanization was researched, the impacts of human activities on ecological connectivity were analyzed, and corresponding strategies to optimize the ecological network were proposed to provides theoretical support and decision-making references for urban ecological protection and sustainable spatial governance. [Methods] Taking Kunming City as a case study, the remote sensing ecological index (RSEI) was employed to assess regional habitat quality. By integrating the XGBoost machine learning model with SHAP interpretability analysis tools, the main driving factors influencing the spatial pattern of RSEI were identified. Based on these driving factors, an ecological resistance surface was constructed. Subsequently, through the application of morphological spatial pattern analysis (MSPA), landscape connectivity index (LCI), and circuit theory, a comprehensive ‘point-line-plane’ ecological security pattern was established. [Results] From 2000 to 2023, Kunming’s ecological security pattern underwent significant changes. Although the area of ecological sources increased by 1 258.50 km2, representing an expansion of the total ecological source area, the number of ecological corridors decreased by 23, with a total length reduced by 201.58 km. Furthermore, the number of ecological pinch points decreased by 14, while ecological barrier points increased by 4. These alterations seriously affected the connectivity of the ecological network and the free migration capacity of species. Due to urban expansion and intensified human activities, the Dianchi Lake periphery emerged as the most severely impacted zone, exhibiting the highest ecological resistance values and facing a high risk of connectivity degradation. [Conclusion] To counter urbanization challenges, Kunming should strengthen ecological source protection, rehabilitate key ecological corridors, reduce human interference with the ecological network, and implement stricter ecological protection measures in the Dianchi Lake periphery to mitigate the negative impacts of urbanization on the ecosystem.