Safe antibiotic substitutes are needed given the rise in antimicrobial resistance, environmental contamination, and stringent antibiotic regulations. Insect-derived antimicrobial peptides (AMPs) are promising candidates due to their antimicrobial activity, stability, and safety. This study investigates the antimicrobial mechanism of crude AMP extracts and their physicochemical characteristics in black soldier fly larvae (BSFL). The results indicated that BSFL reared on a wheat bran diet exhibited significantly improved growth performance and AMP production when compared to the other three diets. AMP extracts showed enhanced antimicrobial activity and physicochemical stability, including temperatures and metal ions except Cu+. Moreover, AMP extracts disrupted the cell membrane and inhibited the cell cycle of Staphylococcus aureus (S. aureus), thus exhibiting antimicrobial activity. Furthermore, transcriptomic and KEGG enrichment analyses identified 509 differentially expressed genes (DEGs) related to the Toll and IMD signaling pathways. STRING and GeneMANIA analyses confirmed the association of these pathways with immune response and AMP secretion. qRT-PCR results showed elevated expression of immune genes (GNBP3, NFKBIA, GADD45, and Spz) in BSFL following S. aureus immunization, consistent with RNA-seq findings. These findings offer a valuable reference for using AMPs as antibiotic substitutes in animal feeds and highlight the need for further research on AMP purification and the synergistic regulation of protein synthesis and AMP production in BSFL.