Abstract Background magnetic field compensation can effectively improve the signalto-noise ratio of biomagnetic field measurements. But for complex environmental disturbances, creating a stable near-zero magnetic field environment is a challenging topic. Therefore, this paper constructs a background magnetic field compensation system based on the Improved Linear Expanded State Observer (ILESO), which effectively reduces the magnetic field fluctuations. Firstly, the system model is obtained based on the input and output characteristics of the system. Then, an improved linear extended state observer is designed to observe and compensate the environmental disturbance, and the adaptive rate is established to balance the estimation capability of the observer and the measurement noise. Finally, the experimental results validate the effectiveness of the proposed method. For 1 Hz disturbances, the peak-to-peak magnetic field value was reduced from 3.71 nT to 0.33 nT. Under the influence of external environmental magnetic field disturbances with an amplitude of 3417 nT within the 0-15 Hz frequency band, the internal magnetic field within the MSR remains consistently stable within 1 nT. These results have a significant reference for obtaining an ultra-stable, near-zero environment.