The loess hilly and gully areas have broken terrain, vertical and horizontal ravines and fragile ecological environments. Improving the resilience of the regional ecological space is conducive to improving the quality of the local ecological environment. With the ecological space of the Yanhe River Basin selected as the research object, this paper constructs a research framework of "network identification topology-resilience evaluation-spatial optimization" and uses morphological spatial pattern analysis (MSPA) and the minimum cumulative resistance model (MCR) to identify ecological spatial networks. Based on circuit theory, the ecological pinch point is identified, the ecological spatial network is optimized, and scenario simulation is performed. Through complex network theory and related indicators, the ecological spatial resilience of the basin is evaluated, and the hierarchical optimization strategy of the ecological space is confirmed. According to the ecological function of the source area and the results of the resilience evaluation, the boundaries of the protected control area, guidance development area, remediation area, and maintenance and improvement area of the basin are delineated. The importance of ecological source and corridor protection is classified, and corresponding protection strategies are proposed. The research results can provide theoretical support and practical guidance for the territorial spatial planning and ecological space construction of the Yanhe River Basin and provide a reference for the ecological restoration, resource development and environmental governance of the Yanhe River Basin.