In nature, larvae of the fruitfly Drosophila melanogaster are commonly infected by parasitoid wasps, and so have evolved a robust immune response to counter wasp infection. In this response, fly immune cells form a multilayered capsule surrounding the wasp egg, leading to death of the parasite. Many of the molecular mechanisms underlying this encapsulation response are conserved with human immune responses. Our findings suggest that protein N-glycosylation, a common protein post-translational modification of human immune proteins, may be one such conserved mechanism. We found that membrane proteins on Drosophila immune cells are N-glycosylated in a temporally specific manner following wasp infection. Furthermore we have identified mutations in eight genes encoding enzymes of the N-glycosylation pathway that decrease fly resistance to wasp infection. More specifically, loss of protein N-glycosylation in immune cells following wasp infection led to the formation of defective capsules, which disintegrated over time and were thereby unsuccessful at preventing wasp development. Interestingly, we also found that one species of Drosophila parasitoid wasp, Leptopilina victoriae, targets protein N-glycosylation as part of its virulence mechanism, and that overexpression of an N-glycosylation enzyme could confer resistance against this wasp species to otherwise susceptible flies. Taken together, these findings demonstrate that protein N-glycosylation is a key player in Drosophila cellular encapsulation and suggest that this response may provide a novel model to study conserved roles of protein glycosylation in immunity.