N-nitrosodimethylamine (NDMA) is an emerging disinfection by-product (DBP) which can be formed via the chloramination of amine-based precursors. The formation of NDMA is mainly determined by the speciation of chloramines and the precursor amine groups, both of which are highly dependent on pH. The impact of pH on NDMA formation has been studied for the model precursor dimethylamine (DMA) and natural organic matter (NOM), but little is known for amine-based pharmaceuticals which have been newly identified as a group of potential NDMA precursors, especially in waters impacted by treated wastewater effluents. This study investigates the role of pH in the formation of NDMA from two amine-based pharmaceuticals, ranitidine and sumatriptan, under drinking water relevant conditions. The results indicate that pH affects both the ultimate NDMA formation as well as the reaction kinetics. The maximum NDMA formation typically occurs in the pH range of 7–8. At lower pH, the reaction is limited due to the lack of non-protonated amines. At higher pH, although the initial reaction is enhanced by the increasing amount of non-protonated amines, the ultimate NDMA formation is limited because of the lack of dichloramine.