Microbial immobilization is considered as a novel and environmentally friendly technology that uses microbes to reduce heavy metals accumulation in plants. To explore microbial resources which are useful in these applications, three water spinach rhizosphere soils polluted by different levels of heavy metals (heavy pollution (CQ), medium pollution (JZ), and relative clean (NF)) were collected. The community composition of heavy metal-immobilizing bacteria in rhizosphere soils and its effects on reducing the Cd2+ and Pb2+ concentrations in water spinach were evaluated. Four hundred strains were isolated from the CQ (belonging to 3 phyla and 14 genera), JZ (belonging to 4 phyla and 25 genera) and NF (belonged to 6 phyla and 34 genera) samples, respectively. In the CQ sample, 137 strains showed a strong ability to immobilize Cd2+ and Pb2+, giving Cd2+ and Pb2+ removal rates of greater than 80% in solution; Brevundimonas, Serratia, and Pseudoarthrobacter were the main genera. In total, 62 strains showed a strong ability to immobilize Cd2+ and Pb2+ in the JZ sample and Bacillus and Serratia were the main genera. A total of 22 strains showed a strong ability to immobilize Cd2+ and Pb2+ in the NF sample, and Bacillus was the main genus. Compared to the control, Enterobacter bugandensis CQ-7, Bacillus thuringensis CQ-33, and Klebsiella michiganensis CQ-169 significantly increased the dry weight (17.16–148%) of water spinach and reduced the contents of Cd2+ (59.78–72.41%) and Pb2+ (43.36–74.21%) in water spinach. Moreover, the soluble protein and Vc contents in the shoots of water spinach were also significantly increased (72.1–193%) in the presence of strains CQ-7, CQ-33 and CQ-169 compared to the control. In addition, the contents of Cd and Pb in the shoots of water spinach meet the standard for limit of Cd2+ and Pb2+ in vegetables in the presence of strains CQ-7, CQ-33 and CQ-169. Thus, the results provide strains as resources and a theoretical basis for the remediation of Cd- and Pb-contaminated farmlands for the safe production of vegetables.