Magnetic separation is used in the domain of water purification. In these systems, functionalized or bare magnetic nanoparticles are used to capture a target pollutant then they are extracted from water by an applied magnetic field. We have shown that a classical aqueous ferrofluid composed by iron oxide nanoparticles covered with an oleic acid double layer allows efficient adsorption of metallic cations (nickel ion Ni2+) followed by nanoparticle extraction with the help of magnetic microparticles. We have shown that strong enough magnetic interactions between nanoparticles can induce a colloidal phase transition. There exists three capture regimes which depend on two parameters, the first one is related to the magnetic field intensity and the second is the nanoparticle concentration. In the presence of the flow of nanoparticle suspension, the nanoparticle capture is always governed by the nanoparticle concentration and also by Mason number. We have carried out an experiment on nanoparticle capture in a porous medium. The filtration efficiency is related to the competition between the hydrodynamic and magnetic forces, as well as to the phase separation in the suspension bulk. The theories developed in the frames of this work show a reasonable agreement with the experimental results. They predict an increase of the capture efficiency with an increase of the magnetic field intensity and the nanoparticle concentration as well as a decrease of the capture efficiency with the growth of the Mason number.