Phosphorous loading in the natural waters is a current issue that is caused by the discharge of industrial water, agriculture run off, and municipal releases. Membrane technology is an emerging method to target the removal of phosphorous from wastewater and has several advantages over the traditional methods. However, the main challenge of membrane technology is membrane fouling. The main goal of this study was to optimize nanofiltration process of phosphates using electromagnetic field (EMF) as an eco-friendly membrane fouling remediation technique. To obtain this, several test runs were performed on a commercial membrane Dow NF270 for nanofiltration of synthesized water with various concentrations of phosphate. The application of EMF altered the particle size of phosphate that resulted in a significant decrease in membrane fouling while obtaining maximum flux. In situ synchrotron-based micro–Computed Tomography imaging (SR-μCT) available at the Canadian Light Source (CLS) was conducted to assess membrane fouling with and without EMF influence across layer by layer across membrane thickness. Synchrotron X-ray analysis revealed the decrease in internal membrane pores fouling, caused by increase of phosphate particles size when using EMF. In addition, SEM images of membrane showed reduced fouling. The influence of flowrate, pressure, pH, and phosphate concentration was observed on permeate volume, permeate flux, and membrane fouling. It was determined that flowrate, transmembrane pressure, and pH had were directly proportional to the permeate volume, while the phosphate concentration was indirectly proportional. Mathematical models were developed to obtain the optimized operating conditions and to determine which factor influenced water flux and membrane fouling the most. The transmembrane pressure was the most significant factor for water permeate flux, while the combination of the influence of pH and feed flowrate had also a positive effect. On the other hand, the feed concentration was the most significant for membrane fouling, according to mathematical model. The optimized conditions with the highest desirability had the concentration of phosphate at 0.368 mg/L, pressure at 97.8 psi, 6.98 pH, and flowrate of 5.13 L/min. Under these conditions, maximum flux of 7.43 mL/cm2/min and minimum fouling of 0.046 mg/cm2 was achieved.