Black soldier fly larvae (BSFL) have been proven to reduce greenhouse gas emissions in the treatment of organic waste (e.g., domestic biodegradable waste, DBW). However, the microbial mechanisms involved have not been fully understood. The current study mainly examined the dynamic changes of carbon and nitrogen, greenhouse gas emissions, the succession of microbial community structure, and changes in gene abundance in DBW under BSFL treatment (LT) and non-aeration composting (NC). We found that of the organic waste supplied, 29.9% carbon and 55.0% nitrogen were stored in BSFL. For every 1kg of dry matter of organic waste consumed, 655 g CO2, 0.80 mg CH4, and 2.26 mg N2O were emitted from LT, significantly lower than those from NC. 16S rRNA gene sequencing results showed that the BSFL increased the relative abundance of Methanophaga, Marinobacter, and Campylobacter during the bioprocess, enhancing the consumption of CH4 and N2O. The metagenomic data showed that the BSFL reduced the ratio of (nirK + nirS + nor)/nosZ in the residues, thereby reducing the emission of N2O. In addition, it increased the functional gene abundance of nirA, nirB, nirD, and nrfA, making nitrite more inclined to be reduced to ammonia. The BSFL mitigated greenhouse gas emissions by redistributing carbon and nitrogen and remodeling the community and function of microbiomes during the DBW bioconversion.