Parasitoids are ubiquitous in natural ecosystems. Parasitic strategies are highly diverse among parasitoid species, yet their underlying genetic bases are poorly understood. Here, we focus on the divergent adaptation of a specialist and a generalist drosophilid parasitoids. We find that a novel protein (Lar) enables active immune suppression by lysing the host lymph glands, eventually leading to successful parasitism by the generalist. Meanwhile, another novel protein (Warm) contributes to a passive strategy by attaching the laid eggs to the gut and other organs of the host, leading to incomplete encapsulation and helping the specialist escape the host immune response. We find that these diverse parasitic strategies both originated from lateral gene transfer, followed with duplication and specialization, and that they might contribute to the shift in host ranges between parasitoids. Our results increase our understanding of how novel gene functions originate and how they contribute to host adaptation.