To explore the coupling mechanism between urban-rural transformation (URT) and the ecological environment in counties forms the basis for achieving high-quality and sustainable county development. Despite the richness of research on the relationship between urban and rural development and the ecological environment, the county level remains the basic unit of rural revitalization in China, and further research on the coupling mechanism between URT and the ecological environment at this level is needed. Therefore, the study developed an evaluation system for URT, incorporated NDVI data indicators, and employed the coupling coordination degree (CCD) model along with GIS tools to investigate the spatio-temporal pattern of URT and NDVI evolution, and the CCD in each administrative village within Lingbao City. Additionally, a geoDetector model was employed to analyze the influencing factors affecting the CCD of URT and NDVI. Finally, the study explores the coupling mechanism and optimization path. The result shows that: (1) During the study period, the URT level in administrative villages within the study area markedly improved, while NDVI exhibited an increasing-then-decreasing trend; (2) The CCD between URT and NDVI in the northern and central regions of the study area is higher than that in the southern region, with an overall low level; (3) The spatial heterogeneity of CCD is significant, largely influenced by socio-economy, natural environment, policy funds, and geographical location, where the elements comprising CCD mutually influence each other; (4) Drawing upon the coupling and coordination dynamics between URT and the ecological environment within Lingbao City, this research categorizes it into seven types with distinct optimization paths. This study provides a valuable reference for guiding the high-quality and sustainable development strategies for mountainous and hilly counties within the Yellow River basin.