Abstract Aedes aegypti mosquitoes are the main vectors of arboviruses. The peritrophic matrix (PM) is an extracellular layer that surrounds the blood bolus and acts as an immune barrier that prevents direct contact of bacteria with midgut epithelial cells during blood digestion. Here, we describe a heme-dependent peroxidase, hereafter referred to as heme peroxidase 1 (HPx1). HPx1 promotes PM assembly and antioxidant ability, modulating vector competence. Mechanistically, the heme presence in a blood meal induces HPx1 transcriptional activation mediated by the E75 transcription factor. HPx1 knockdown increases midgut reactive oxygen species (ROS) production by the DUOX NADPH oxidase. Elevated ROS levels reduce microbiota growth while enhancing epithelial mitosis, a response to tissue damage. However, simultaneous HPx1 and DUOX silencing was not able to rescue bacterial population growth, as explained by increased expression of antimicrobial peptides (AMPs), which occurred only after double knockdown. This result revealed hierarchical activation of ROS and AMPs to control microbiota. HPx1 knockdown produced a 100-fold decrease in Zika and Dengue 2 midgut infection, demonstrating the essential role of the mosquito PM in the modulation of arbovirus vector competence. Our data show that the PM connects blood digestion to midgut immunological sensing of the microbiota and viral infections.