A method and apparatus for selective removal of heavy ions, biological, cations, anions or other elements of interest from liquids using magnetic nanoparticles, and recovery of nanoparticles to be reused in the wastewater purification. For certain embodiments, after water treatment and magnetic separation, the loaded nanoparticles may be washed, regenerated, collected and re-introduced in the water treatment cycle. Water treatment and particle regeneration take place singly or simultaneously. In another disclosed embodiment of the process, the electricity consumed by the pumping system is supplied by renewable energy sources such as solar, wind, geothermal, biogas or small hydro.