Anopheles gambiae, the major vector for the protozoan malaria parasite Plasmodium falciparum, mounts powerful antiparasitic responses that cause marked parasite loss during midgut invasion. Here, we showed that these antiparasitic defenses were composed of pre- and postinvasion phases and that the preinvasion phase was predominantly regulated by Rel1 and Rel2 members of the NF-kappaB transcription factors. Concurrent silencing of Rel1 and Rel2 decreased the basal expression of the major antiparasitic genes TEP1 and LRIM1 and abolished resistance of Anopheles to the rodent malaria parasite P. berghei. Conversely, depletion of a negative regulator of Rel1, Cactus, prior to infection, enhanced the basal expression of TEP1 and of other immune factors and completely prevented parasite development. Our findings uncover the crucial role of the preinvasion defense in the elimination of parasites, which is at least in part based on circulating blood molecules.