As the important coal bases in northwestern China, the hydrological and ecological environment of Ordos, northern Shaanxi (Shanbei) and Shanxi Province has attracted more and more attention. Terrestrial water storage anomaly (TWSA) and precipitation, as important hydrological elements, play an important role in the distribution and growth of vegetation. In this paper, the Gravity Recovery and Climate Experiment (GRACE) satellite data, Tropical Rainfall Measuring Mission (TRMM) precipitation data, and the Remote Sensing Ecological Index (RSEI) were used to analyze the spatial-temporal changes and coupling relationships of TWSA, precipitation and ecological environment from 2002 to 2020. The numerical results showed the TWSA in the study area has a decreasing trend and the rates are -6.19mm/a, -7.67mm/a and -16.92mm/a for Ordos, Shanbei and Shanxi Province, respectively. On the contrary, the precipitation appeared an increasing trend and the rates are 0.35mm/a, 0.63mm/a and 0.18mm/a for these three sub-regions. It is found that the precipitation is not the main factor causing the variation of TWSA, but the coal mining activities and artificial irrigation activities, which is especially clear in the Taihang Mountains in eastern of Shanxi Province. The ecological environment has been improving, and TWSA and precipitation are the important hydrological factors causing this change. Precipitation is the main reason for improving the ecological environment in three sub-regions on a seasonal scale, especially in summer. The research results are helpful to understand the impact of hydrological changes on the ecological environment, which play an important role in environmental governance in coal mining areas.