N-nitrosodimethylamine (NDMA) as a disinfection by-product has recently become the focus of considerable research interest due to its unusually high carcinogenicity. In this study, the formation mechanisms of NDMA from dimethylamine (DMA) during chloramination and ozonation were investigated by using the quantum chemical G4 method. The reactivity of haloamines and hydroxylamine reacting with DMA was found in the order: NHCl2∼NHBrCl (Brˉleaving)>NHBr2>NH2Cl∼NH2Br>>NH2OH. This offers a theoretical support for the experimentally proposed mechanism that dimethylamine reacts with NHCl2 rather than NH2Cl to form chlorinated unsymmetrical dimethylhydrazine intermediate and the existence of bromochloramine in the presence of bromide during chloramination, and explains the observation that NDMA yield during ozonation is much lower than that during chloramination. Importantly, an N,N-dimethylaminonitrene was found to be a significant intermediate to form NDMA in oxidation reactions by molecular oxygen and ozone. Additionally, results suggest that the amines containing the second nitrogen source directly connecting or close to the N-(CH3)2 moiety are potential significant NDMA precursors upon ozonation. The findings of this study are helpful for expanding the knowledge of NDMA formation mechanism, and predicting potential NDMA precursors during disinfection.