Despite the prevalence of well-established and explored navigation systems, alternative localization methods are currently the focus of intensive research. This interest is driven by geopolitical challenges and increasingly sophisticated applications of mobile robots and uncrewed aerial vehicles. This study investigates the problem of real-time positioning in GPS-denied environments. Based on the mapped magnetic anomaly field and using Bayesian formalism for data fusion, the localization obtained from embedded sensors is corrected to reduce cumulative errors. The proposed method has minimal computational cost and a minimal number of tunable parameters. The paper introduces it and demonstrates its effectiveness in a laboratory study. Experimental tests, using a system equipped with an Inertial Measurement Unit, demonstrated a significant reduction in localization uncertainty. The improvement was especially notable in areas with large, smooth variations in the magnetic field. Finally, the accuracy of the method is analyzed, and its performance is compared to a particle filter.