The aim of this study was to reveal the spatiotemporal pattern of the supply and demand of ecosystem services (ESs), as well as the significant driving factors for understanding the impact of human activities on the natural ecosystem. To provide a scientific basis for formulating regional sustainable development strategies that enhance human well-being, resource-based cities in the Yellow River Basin (YRB) were selected as the case study. The supply and demand of ecosystem services in these cities from 2000 to 2020 were measured. The spatiotemporal evolution of the supply-demand relationship was illustrated by taking its coordination degree. In addition, geographical detector and geographically weighted regression (GWR) models were applied to quantify the spatiotemporally varying effects of natural and socioeconomic factors on the ES supply--demand relationship. The results showed that resource-based cities in the YRB were experiencing expansion in supply and demand overall, but the supply-demand relationship tended to be tense. The northwest YRB had higher coordination values of supply-demand, while lower values were found in the southeast YRB. Moreover, the relationship between supply and demand was significantly affected by natural and socioeconomic factors, such as elevation, slope, precipitation, land-use type, population density, and gross domestic product (GDP) per land. Furthermore, the GWR model suggested that the effects of driving factors on the supply-demand relationship had notable spatial heterogeneity. The coordination of ES supply-demand in the resource-based cities of southeast YRB was mainly influenced by socioeconomic factors, while that of the west YRB was mainly influenced by natural factors. Our study suggested that it is necessary to enhance the awareness of environmental protection, pay attention to ecological restoration, and avoid unreasonable human disturbance to the ecosystem.