In many animal species, females and males differ in physiology, lifespan, and immune function. The magnitude and direction of the sexual dimorphism in immune function varies greatly and the genetic and mechanistic bases for this dimorphism are often unknown. Here we show that Drosophila melanogaster females are more likely than males to die from infection with several strains of the fungal entomopathogen Beauveria bassiana. The sexual dimorphism is not exclusively due to barrier defenses and persists when flies are inoculated by injection as well as by surface exposure. Loss of function mutations of Toll pathway genes remove the dimorphism in survivorship. Surprisingly, loss of function mutation of relish, a gene in the Imd pathway, also removes the dimorphism, but the dimorphism persists in flies carrying other Imd pathway mutations. The robust sexual dimorphism in D. melanogaster survival to B. bassiana presents opportunities to further dissect its mechanistic details, with applications for biological control of insect vectors of human disease and insect crop pests.