Nitrosamines are a class of carcinogenic, mutagenic, and teratogenic compounds generally produced from the nitrosation of amine. This paper investigates the mechanism for the formation of nitrosodimethylamine (NDMA) from the nitrosation of dimethylamine (DMA) by four common nitrosating agents (NO2–, ONOO–, N2O3, and ONCl) in the absence and presence of CO2 using the DFT method. New insights are provided into the mechanism, emphasizing that the interactions of CO2 with amine and nitrosating agents are both potentially important in influencing the role of CO2 (catalyst or inhibitor). The role of CO2 as catalyst or inhibitor mainly depends on the nitrosating agents involved. That is, CO2 shows the catalytic effect when the weak nitrosating agent NO2– or ONOO– is involved, whereas it is an inhibitor in the nitrosation induced by the strong nitrosating agent N2O3 or ONCl. To conclude, CO2 serves as a “double-edged sword” in the nitrosation of amine. The findings will be helpful to expand our understanding of the pathophysiological and environmental significance of CO2 and to develop efficient methods to prevent the formation of carcinogenic nitrosamines