The portable X-ray fluorescence (pXRF) spectrometer is widely employed for in situ analysis of both contaminated and uncontaminated soils. However, the accuracy of the measurements can be significantly affected by soil moisture, resulting in unreliable soil pollution monitoring. This effect has already been studied and quantified, but this is ineffective if the soil moisture in the field is unknown. Given the considerable variability of soil moisture conditions across time and space, significant bias during in situ investigations remains a main issue. This study introduces a novel method to estimate soil moisture directly from pXRF field measurements, enabling its reliable use in almost any field condition. The study was conducted using soil samples and in situ pXRF soil surface measurements in Estarreja (Portugal) and Vicdessos (France). In the first experiment, the innovative approach involved modeling soil moisture directly from the raw XRF measurement errors obtained in moist soils using multiple regression. In the second experiment, metal concentrations were modeled as an exponential function of the moisture content. The final model integrates both approaches to correct field data from geochemical mapping in diverse environments, including a coastal region in Portugal and a mountainous region in France. Our findings demonstrate that this simple, efficient and cost-effective method accurately predicts soil moisture (U) using pXRF, as shown by the equation Umeasured = 1.0028 x Uestimated (r2 = 0.9715). The model effectively corrected up to 70% of moisture-induced errors in metal concentrations in the wettest soils and produced more reliable soil Fe, Pb, and Zn maps. Specifically, the accuracy improvement was at least 32% in drier soils (Portugal) and at least 55% in wetter soils (France). This study offers a cost-effective, efficient solution for employing pXRF in geochemical mapping across different climatic conditions and soil environments.