So far, a large number of studies have quantified the effect of COVID-19 lockdown measures on air quality in different countries worldwide. However, few studies have compared the influence of different approaches on the estimation results. The present study aimed to utilize a random forest machine learning approach as well as a difference-to-difference approach to explore the effect of lockdown policy on nitrogen dioxide (NO2) concentration during COVID-19 outbreak period in mainland China. Datasets from 2017 to 2019 were adopted to establish the random forest models, which were then applied to predict the NO2 concentrations in 2020, representing a scenario without the lockdown effect. The results showed that random forest models achieved remarkable predictive accuracy for predicting NO2 concentrations, with index of agreement values ranging between 0.34 and 0.76. Compared with the modelled NO2 concentrations, on average, the observed NO2 concentrations decreased by approximately 16 µg/m3 in the lockdown period in 2020. The difference-to-difference approach tended to underestimate the influence of COVID-19 lockdown measures. Due to the improvement of NO2 pollution, around 3722 non-accidental premature deaths were avoided in the studied population. The presented machine learning modelling framework has a great potential to be transferred to other short-term events with abrupt pollutant emission changes.