Surfactants are widely used as a passivating agent in heavy metal passivation process, but their effect on transformation of heavy metal fraction and reduction of heavy metal resistance genes (MRGs) in composting process is still unknown. The aim of this study was to compare the effects of two anionic surfactants (rhamnolipid and sodium dodecyl sulfate) on heavy metal passivation and resistance gene reduction in chicken manure composting. The results showed that the addition of surfactant can effectively enhance degradation of organic matter (OM). Both surfactants could effectively reduce the bioavailability of heavy metals (HMs) and the relative abundance of resistance genes, especially rhamnolipids. The potential functional bacteria affecting heavy metal passivation were identified by the changes of microbial community. Redundancy analysis (RDA) showed that protease (PRT) activity was the key factor affecting the fractions of the second group of HMs including ZnF1, CuF1, CuF2, PbF1 and PbF3. These findings indicate that addition of anionic surfactants can reduce the bioavailability of HMs and the abundance of resistance genes in compost products, which is of guiding significance for the reduction of health risks in the harmless utilization of livestock and poultry manure.