Excessive accumulation of total petroleum hydrocarbons (TPH) and heavy metals (HMs) in sediments poses a significant threat to the estuarine ecosystem. In this study, the spatial and temporal distribution, ecological risks, sources, and their impacts on the microbial communities of TPH and nine HMs in the estuarine sediments of the Xiaoqing River were determined. Results showed that the spatial distribution of TPH and HMs were similar but opposite in temporal. Ni, Cr, Pb, and Co concentrations were similar to the reference values (RVs). However, the other five HMs (Cu, Zn, Cd, As, and Hg) and TPH concentrations were 2.00–763.44 times higher than RVs; hence, this deserves attention, particularly for Hg. Owing to the water content of the sediments, Hg was mainly concentrated on the surface during the wet season and on the bottom during the dry season. Moreover, because of weak hydrodynamics and upstream pollutant sinks, TPH–HMs in the river were higher than those in the estuary. TPH and HM concentrations were negatively correlated with microbial diversity. Structural equation modeling showed that HMs (path coefficient = −0.50, p < 0.001) had a negative direct effect on microbial community structure and a positive indirect effect on TPH. The microbial community (path coefficient = 0.31, 0.01 < p < 0.05) was significantly correlated with TPH. In summary, this study explores both the chemical analysis of pollutants and their interaction with microbial communities, providing a better understanding of the co-pollution of TPH and HMs in estuarine sediments.