Mosquitoes have evolved an effective innate immune system. The mosquito gut accommodates various microbes, which play a crucial role in shaping the mosquito immune system during evolution. The resident bacteria in the gut microbiota play an essential role in priming basal immunity. In this study, we show that antibacterial immunity in Anopheles gambiae can be enhanced by priming via a sugar meal supplemented with bacteria. Serratia fonticola S1 and Enterobacter sp. Ag1 are gut bacteria in mosquitoes. The intrathoracic injection of the two bacteria can result in an acute hemocoelic infection in the naïve mosquitoes with mortality of ∼40% at 24 h post-infection. However, the Enterobacter orSerratia primed mosquitoes showed a better 24 h survival upon the bacterial challenge. The priming confers the protection with a certain degree of specificity, the Enterobacter primed mosquitoes had a better survival upon the Enterobacter but not Serratia challenge, and the Serratia primed mosquitoes had a better survival upon the Serratia but not Enterobacter challenge. To understand the priming-mediated immune enhancement, the transcriptomes were characterized in the mosquitoes of priming as well as priming plus challenges. The RNA-seq was conducted to profile 10 transcriptomes including three samples of priming conditions (native microbiota, Serratia priming, and Enterobacter priming), six samples of priming plus challenges with the two bacteria, and one sample of injury control. The three priming regimes resulted in distinctive transcriptomic profiles with about 60% of genes affected by both bacteria. Upon challenges, different primed mosquitoes displayed different transcriptomic patterns in response to different bacteria. When a primed cohort was challenged with a heterogenous bacterium, more responsive genes were observed than when challenged with a homogenous bacterium. As expected, many canonical immune genes were responsive to the priming and challenge, but much more non-immune genes with various functions were also responsive in the contexts, which implies that the prior priming triggers a delicately coordinated systemic regulation that results in an enhanced immunity against the subsequent challenge. Besides the participation of typical immune pathways, the transcriptome data suggest the involvement of lysosome and metabolism in the context. Overall, this study demonstrated a trained immunity via priming with bacteria in diet.