To evaluate the interactions among endophytes, plants and heavy metal/arsenic contamination, root endophytic bacteria of Prosopis laevigata (Humb and Bonpl. ex Willd) and Sphaeralcea angustifolia grown in a heavy metal(loid)-contaminated zone in San Luis Potosi, Mexico, were isolated and characterized. Greater abundance and species richness were found in Prosopis than in Sphaeralcea and in the nutrient Pb-Zn-rich hill than in the poor nutrient and As-Cu-rich mine tailing. The 25 species identified among the 60 isolates formed three groups in the correspondence analysis, relating to Prosopis/hill (11 species), Prosopis/mine tailing (4 species) and Sphaeralcea/hill (4 species), with six species ungrouped. Most of the isolates showed high or extremely high resistance to arsenic, such as ≥100 mM for As(V) and ≥20 mM for As(III), in mineral medium. These results demonstrated that the abundance and community composition of root endophytic bacteria were strongly affected by the concentration and type of the heavy metals and metalloids (arsenic), as well as the plant species.