Graphical abstract Highlights • Amaranthus retroflexus increased diversity and richness of soil N-fixing bacterial communities (SNB). • Heavy metal pollution (HMP) decreased number of species and richness of SNB. • Combined A. retroflexus and HMP decreased total number of all species of SNB. • Combined A. retroflexus and HMP decreased richness of SNB. Abstract Soil nitrogen (N) availability is generally considered as the mainly driving force of successful colonization of many kinds of invasive plant species. Meanwhile, the vast majority of biologically available N in ecosystems mainly originates from soil N-fixing bacterial communities (SNB) primarily via biological N-fixation. The progressive shifts in the components of heavy metal pollution (HMP) can cause obvious changes in soil microbial communities (especially SNB). This study aims to comprehensively analyze the effects of redroot pigweed (Amaranthus retroflexus L.) invasion on the community structure of SNB under Cu and Cd heavy metal soil pollution (independent copper (Cu), independent cadmium (Cd), and combined Cu and Cd) by using high-throughput sequencing. The positive effects of redroot pigweed invasion on the total number of all species, the number of species, the diversity, and the richness of SNB may be that redroot pigweed can trigger obvious variation in soil nutrient content (especially N), a key driver of the community structure of SNB, via the root exudates and/or leaf litters. The negative effects of HMP on the number of species and the richness of SNB may be attributed to the additional energy cost to SNB and/or the decreased soil pH under HMP. The effects of the combined Cu and Cd on the total number of all species and the richness of SNB were higher than those under the independent Cu and Cd. This may be due to the stronger oxidative stress under the combined heavy metals. The negative effects of redroot pigweed invasion treatment with all types of HMP on the total number of all species and the richness of SNB may be ascribed to the shifts in soil physicochemical properties (especially the stronger acidification) and the additional energy cost which can wave remarkably effects on the abundance of the nifH gene. Accordingly, the invasion of redroot pigweed may be inhibited under HMP as a result of the shifts in certain species of SNB and the decreased the total number of all species and the richness of SNB. [ABSTRACT FROM AUTHOR]