Heavy metals (HMs) profoundly impact soil carbon storage potential primarily through soil carbon structure. The association between HM content and soil carbon structure in mangrove sediments remains unclear, likely due to the involvement of microorganisms. In this study, surface sediments in the Futian National Mangrove Nature Reserve were sampled to investigate the chemical structure of soil organic carbon (SOC), the molecular composition of dissolved organic matter (DOM), and potential interactions with microorganisms. HMs, except for Ni, were positively correlated with soil carbon. HMs significantly reduced the alkyl C/O-alkyl C ratio, aromaticity index, and aromatic C values, but increased the labile carboxy/amide C and carbonyl C ratio in SOC. HMs also increased DOM stability, as reflected by the reduced abundance of labile DOM (lipids and proteins) and increased proportion of stable DOM (tannins and condensed aromatics). Bacteria increased the decomposition of labile DOM components (unsaturated hydrocarbons) and the accumulation of stable DOM components (lignins) under HM enrichment. In addition, the association between the bacterial groups and DOM molecules was more robust than that with fungal groups, indicating bacteria had a more significant impact on DOM molecular composition. These findings help in understanding the molecular mechanisms of soil carbon storage in HM-rich mangroves.