Pistacia lentiscus L. is an excluder metallophyte proposed for the revegetation and phytostabilization of metal-contaminated sites in the Mediterranean area. The present study aims at evaluating the linking between bacterial communities and plants spontaneously growing in ecosystems chronically impacted by mining activities. Environmental properties and metal accumulation into hypogeal and epigeal tissues were analyzed in wild plants of two contrasting habitats with extreme metal contamination (> 2300mg/kg for Zn, > 1100mg/kg for Pb, > 10mg/kg for Cd). The community structures of rhizospheric and root endophytic bacteria were fingerprinted by terminal restriction fragment length polymorphism of the 16S rRNA gene. The wild shrubs efficiently restrict the accumulation of the three major contaminants to the epigeal tissues in the two habitats under study (249 ± 68mg/kg dw for Zn, 43 ± 21mg/kg dw for Pb, and 1.4 ± 0.5mg/kg dw for Cd). Evidence was provided that the combined but not individual effect of environmental conditions (moisture, inorganic carbon, pH) and proportion between Zn and Cd in the mine substrate play a role in structuring rhizosphere bacterial communities. The observed changes in community structures of root endophytes were found to be strongly associated with Pb level in roots and substrate properties (inorganic carbon and Zn/Cd ratio). Overall, our study highlights the importance of the analysis of multifactorial interactions among mine substrate, plant, and microbes for understanding how the environmental context affects phytoremediation under real conditions.