Grassland ecosystems store approximately one-third of the global terrestrial carbon stocks, which play a crucial role in regulating the carbon cycle on regional and global scales, but the current scientific understanding of the variation in net carbon dioxide exchange (NEE) on grassland ecosystems is still limited. Based on the eddy covariance technique, this study investigated the seasonal variation of ecosystem respiration (Reco) and gross primary production (GPP) from 2018 to 2020 in a semi-arid grassland on the Loess Plateau in northwest China. The results indicated that the annual cumulative average NEE value was − 0.778 kg C/m2, the growing season cumulative value accounted for approximately 83.81%, which suggested that the semiarid grassland showed a notable soil carbon sink. The correlation analysis revealed that soil temperature (Ts) (RReco = 0.71, RGPP = 0.61) and soil water content (SWC) (RReco = 0.47, RGPP = 0.44) were the two main driving factors in modulating the variation of daily average GPP and Reco (P < 0.01). Therefore, the monthly average of GPP and Reco increased with the increase in Ts (RGPP = 0.716, P < 0.01; RReco = 0.586, P < 0.05), resulting in an increase in the carbon sequestration capacity of the grass ecosystem. This study also showed that soil moisture has a promoting effect on the response of Reco and GPP to Ts, and the correlation among GPP, Reco, and Ts was much stronger under wet conditions. For instance, the coefficient of determination of Reco and GPP with Ts under wet conditions in 2018 increased by 0.248 and 0.286, respectively, compared to those under droughty conditions. Additionally, the temperature sensitivity of Reco (Q10) increased by 46.13% compared to dry conditions. In addition, carbon exchange models should consider the synergistic effect of Ts and SWC as one of the main driving factors for theoretical interpretation or modeling. Under the potential scenario of future global warming and the frequent extreme weather events, our findings have important implications for predicting future CO2 exchange and establishing an optimal ecological model of carbon flux exchange.