The aim of this study was to investigate phosphorus removal in water by using a polyampholyte obtained by the reaction of methacrylic acid, ethylene glycol diglycidyl ether and imidazole by a one step synthesis, mixed with diatomaceous earth. The material was characterized before and after phosphorus exposure using FT-IR, Raman, and solid state 31P-NMR and 13C-NMR spectroscopy concluding that the charged imidazole units were involved in the interaction between the phosphorus and the polyampholyte and that only the H2PO4- species was adsorbed. The point of zero charge value was 5.09. Concomitantly, the optimal pH for P adsorption was 5.0. As pH was increased, the polymer turned more negative, and the phosphate repulsion diminished the adsorption. In the batch experiments, the adsorption isotherms at pH values 5.0 and 7.0 were studied. The effects of different flow rates, P influent concentration and the interference of nitrate and sulfate in the breakthrough curves were studied. A shorter breakthrough time occurred at a higher flow rate. The q0 values not only increased from lower to higher influent levels but also showed a decrease in the presence of S and N as interferents demonstrating that there was a competition for the adsorption sites between those anions and the phosphate. © 2017 The Royal Society of Chemistry and the Centre National de la Recherche Scientifique.