Objective To investigate the effects of capsaicin on gut microbiota and antimicrobial peptide expression of Anopheles stephensi, providing experimental references for the application of capsaicin in mosquito-borne disease prevention and control. Methods Anopheles stephensi were continuously fed with sugary water containing capsaicin or DMSO for the capsaicin-treated group and the control, respectively. The DNA of the female mosquito's midguts and gut bacteria was extracted. Bacterial 16S rDNA high-throughput sequencing and real-time fluorescence quantitative PCR were used to analyze and compare the bacteria diversity, gut flora composition, relative abundance, and total bacterial load in female mosquitoes' midgut between the control and capsaicin treatment groups. Total RNA was extracted from the midguts of the two groups of Anopheles mosquitoes, and the transcriptional levels of important antimicrobial peptides were detected and compared by reverse transcription and real-time fluorescence quantitative PCR. Results A total of 10 phyla, 11 classes, 28 orders, 43 families, and 62 genera were identified in the two groups. The capsaicin-treated group had fewer taxa, with significantly reduced bacterial diversity, and different community composition and relative abundance of the flora compared to the control group. At the phylum level, Bacteroidota, Proteobacteria, and Firmicutes predominated in both two groups. At the order level, Flavobacteriales, Acetobacterales, Pseudomonadales, and Lactobacillales were the dominant bacteria, with reduced relative abundance of Pseudomonadales and Acetobacterales and increased relative abundance of Flavobacteriales and Lactobacillales in the capsaicin-treated group. At the genus level, Elizabethkingia was predominantly abundant in both samples, with higher relative abundance of Elizabethkingia, Leuconostoc, and Gluconobacter in the capsaicin-treated group, while Asaia and Acinetobacter had significantly lower relative abundance compared to the control group. In addition to these changes, the total bacterial load was increased and the transcriptional levels of attacin C, cecropin A, and defensin were significantly decreased by capsaicin treatment. Conclusions Capsaicin treatment significantly affects the composition of the gut flora in Anopheles stephensi and increases the total bacterial load while inhibiting the expression of antimicrobial peptides. Based on the analysis, it indicates that capsaicin might affect the fecundity and vector competence of Anopheles by changing the energy metabolism and immune-related bacteria. [ABSTRACT FROM AUTHOR]