Microorganisms play a fundamental role in biogeochemical cycling and are highly sensitive to environmental factors, including the physiochemical properties of the soils and the concentrations of heavy metals/metalloids. In this study, high-throughput sequencing of the 16S rRNA gene was used to study the microbial communities of farmland soils in farmland in the vicinity of a lead–zinc smelter. Proteobacteria, Acidobacteria, Actinobacteria, Bacteroidetes, and Gemmatimonadetes were the predominant phyla in the sites of interest. Sphingomonas, Gemmatimonas, Lysobacter, Flavisolibacter, and Chitinophaga were heavy metal-/metalloid-tolerant microbial groups with potential for bioremediation of the heavy metal/metalloid contaminated soils. However, the bacterial diversity was different for the different sites. The contents of heavy metal/metalloid species and the soil properties were studied to evaluate the effect on the soil bacterial communities. The Mantel test revealed that soil pH, total cadmium (T-Cd), and available arsenic played a vital role in determining the structure of the microbial communities. Further, we analyzed statistically the heavy metals/metalloids and the soil properties, and the results revealed that the microbial richness and diversity were regulated mainly by the soil properties, which correlated positively with organic matter and available nitrogen, while available phosphorus and available potassium were negatively correlated. The functional annotation of the prokaryotic taxa (FAPROTAX) method was used to predict the function of the microbial communities. Chemoheterotrophy and airborne chemoheterotrophy of the main microbial community functions were inhibited by soil pH and the heavy metals/metalloids, except in the case of available lead. Mantel tests revealed that T-Cd and available zinc were the dominant factors affecting the functions of the microbial communities. Overall, the research indicated that in contaminated soils, the presence of multiple heavy metals/metalloids, and the soil properties synergistically shaped the structure and function of the microbial communities.