LISA Pathfinder (LPF) has been a space-based mission designed to test new technologies that will be required for a gravitational wave observatory in space. Magnetically driven forces play a key role in the instrument sensitivity in the low-frequency regime (mHz and below), the measurement band of interest for a space-based observatory. The magnetic field can couple to the magnetic susceptibility and remanent magnetic moment from the test masses and disturb them from their geodesic movement. LISA Pathfinder carried on-board a dedicated magnetic measurement subsystem with noise levels of 10 nT Hz −1/2 from 1 Hz down to 1 mHz. In this paper we report on the magnetic measurements throughout LISA Pathfinder operations. We characterise the magnetic environment within the spacecraft, study the time evolution of the magnetic field and its stability down to 20 µHz, where we measure values around 200 nT Hz −1/2 and identify two different frequency regimes, one related to the interplanetary magnetic field and the other to the magnetic field originating inside the spacecraft. Finally, we characterise the non-stationary component of the fluctuations of the magnetic field below the mHz and relate them to the dynamics of the solar wind.