In this paper, we provide a more accurate description of the evolution of the magnetic flux redistribution during prestellar core collapse by including resistive terms in the magnetohydrodynamics (MHD) equations. We focus more particularly on the impact of ambipolar diffusion. We use the adaptive mesh refinement code RAMSES to carry out such calculations. The resistivities required to calculate the ambipolar diffusion terms were computed using a reduced chemical network of charged, neutral and grain species. The inclusion of ambipolar diffusion leads to the formation of a magnetic diffusion barrier in the vicinity of the core, preventing accumulation of magnetic flux in and around the core and amplification of the field above 0.1G. The mass...