Honeybees (Apis mellifera) are important economic insects and play important roles in pollination and maintenance of ecological balance. However, the use of pesticides has posed a substantial threat to bees in recent years, with the more widely used deltamethrin being the most harmful. In this study, we found that deltamethrin exposure significantly reduced bee survival in a dose-dependent manner (p = 0.025). In addition, metagenomic sequencing further revealed that DM exposure significantly reduced the diversity of the bee gut microbiota (Chao1, p < 0.0001; Shannon, p < 0.0001; Simpson, p < 0.0001) and decreased the relative abundance of core species of the gut microbiota. Importantly, in studies of GF-bees, we found that the colonization of important gut bacteria such as Gilliamella apicola and Lactobacillus kunkeei significantly increased bee resistance to DM (survival rate increased from 16.7 to 66.7%). Interestingly, we found that the immunity-genes Defensin-2 and Toll were significantly upregulated in bees after the colonization of gut bacteria. These results suggest that gut bacteria may protect against DM stress by improving host immunity. Our findings provide an important rationale for protecting honeybees from pollutants from the perspective of gut microbes.