Microorganisms and associated membrane lipids exhibit a remarkable sensitivity to ambient environmental fluctuations, rendering them invaluable for deciphering changes in the past environment. Among these lipids, 3-hydroxy fatty acids (3-OH-FAs), prevalent in the membrane of Gram-negative bacteria, have been recently developed as promising tools for palaeo-temperature and palaeo-pH reconstruction. Recent studies suggested that different mechanisms might cause the observed correlations of 3-OH-FAs with temperature or pH, and bacterial community variation is likely an important explanation for the pH-related correlation. Despite this, direct examinations of the role of the Gram-negative bacterial community in influencing the distribution of 3-OH-FAs and, consequently, impacting the 3-OH-FA-based pH proxies are notably absent in current literature. In this study, we collected acidic, neutral, and alkaline soil samples from Mt. Fanjing, Haozhuzi Cave's overlying soil, and Chenghai Lake's lakeside area in China, respectively, with pH ranging from 3.53 to 10.63. These sites display pronounced pH gradients while showing limited variation in other environmental parameters, such as mean annual air temperature (MAAT). We found that soil pH significantly influences the bacterial community and 3-OH-FA distribution. Furthermore, we observed that the Gram-negative bacterial community primarily comprises Proteobacteria, Acidobacteria, and Bacteroidetes, with each phylum exhibiting a distinct capacity for synthesising specific 3-OH-FAs. These findings suggest that fluctuations in soil pH drive shifts in the abundance of these phyla, thereby inducing alterations in soil 3-OH-FA distribution. Hierarchical partitioning further numerically emphasises the important role of community dynamics in shaping 3-OH-FA distribution. Therefore, in addition to membrane adaptation, changes in Gram-negative bacterial community under strong pH stress will significantly influence the distribution of 3-OH-FAs, consequently influencing the related pH proxies.