Urban air pollution has severe negative effects on health and the economy, especially in developing and industrializing countries, such as China and India. Although the transportation sector is widely acknowledged as among the largest contributors to urban air pollution, quantifying its causal effects on air pollution is challenging, as decisions to travel are endogenous with air quality. The spread of COVID-19 offers a unique opportunity for causal identification, as the pandemic directly affects decisions to travel but has little direct effect on air pollution. Leveraging the number of COVID-19 infections and COVID-19-related queries to online search engines as instruments for decisions to travel, controlling for two-way fixed effects, we quantify the effects of three public transportation subsectors (buses, railways, and taxis) and private vehicles on six primary air pollutants (CO, NO2, O3, PM2.5, PM10, and SO2) of 36 central cities of China, using two-stage ridge regression and double/debiased machine-learning models. Our work demonstrates that the negative effects of urban transportation on air quality are likely to be significantly underestimated without addressing endogeneity in the observational data. Further, our estimates after addressing endogeneity indicate that the effects of public transportation and private vehicles on different air pollutants are heterogeneous. Notably, our work shows that air pollution shifts the demand from mass transportation (buses and railways) to taxis. These findings have implications for sustainable transportation planning, operation, and policy evaluation.