Intestinal microbiota and metal regulatory proteins (MRPs) underlie the transformation of heavy metals (HMs) by the black soldier fly larvae (BSFL), but the mechanisms involved are still not fully defined. Here, using 16S rRNA and metagenomics-assisted tracing, we found that zinc (Zn) and chromium (Cr) stress led to enrichment of Proteobacteria in the BSFL intestine. Support of Proteobacteria also led to increased levels of the Zn transporter proteins ZnuC/B/A and the Zn efflux proteins zntR/A. Meanwhile, the genes MltE, CitT, and SLT, which mediate the citric acid cycle, were also significantly up-regulated and involved in the cellular uptake of Cr. Although Zn and Cr stress affected the expression of antibiotic resistance genes and pathogenic genes, the BSFL intestine tended to form stable microbial communities (MCs) to transform HMs through a mechanism driven by ZupT and chrA. In addition, the expression of SCARB1 and LdcA was significantly down-regulated by acute HMs stimulation, but BSFL were still able to complete the life cycle. Therefore, we determined the protective role of MCs and MRPs on BSFL during the transformation of HMs.