Insects respond to microbial infection by the rapid and transient expression of several genes encoding potent antimicrobial peptides. Herein we demonstrate that this antimicrobial response of Drosophila is not aspecific but can discriminate between various classes of microorganisms. We first observe that the genes encoding antibacterial and antifungal peptides are differentially expressed after injection of distinct microorganisms. More strikingly, Drosophila that are naturally infected by entomopathogenic fungi exhibit an adapted response by producing only peptides with antifungal activities. This response is mediated through the selective activation of the Toll pathway.