The Drosophila immune system discriminates between different classes of infectious microbes and responds with pathogen-specific defense reactions through selective activation of the Toll and the immune deficiency (Imd) signaling pathways. The Toll pathway mediates most defenses against Gram-positive bacteria and fungi, whereas the Imd pathway is required to resist infection by Gram-negative bacteria. The bacterial components recognized by these pathways remain to be defined. Here we report that Gram-negative diaminopimelic acid-type peptidoglycan is the most potent inducer of the Imd pathway and that the Toll pathway is predominantly activated by Gram-positive lysine-type peptidoglycan. Thus, the ability of Drosophila to discriminate between Gram-positive and Gram-negative bacteria relies on the recognition of specific forms of peptidoglycan.