Chemical defense mechanisms are widespread among insects but have rarely been demonstrated in parasitoid wasps. Here, we show that the Drosophila parasitoid Leptopilina heterotoma (Hymenoptera, Figitidae) produces (−)-iridomyrmecin and (+)-isoiridomyrmecin in a cephalic gland, and that these chemicals have a highly repellent effect on ants. Stereoselective synthesis of 4 stereoisomers of iridomyrmecin allowed us to demonstrate that the repellent effect of iridomyrmecins depends on the stereochemistry. Potential food items impregnated with natural doses of (−)-iridomyrmecin were avoided by ants much longer than those impregnated with (+)-iridomyrmecin, (+)-isoiridomyrmecin, or (−)-isoiridomyrmecin, respectively. Quantitative headspace analyses revealed furthermore that females and males of L. heterotoma released iridomyrmecins in higher amounts when confronted with ants. This is the first time, that (−)-iridomyrmecin and (+)-isoiridomyrmecin are reported as natural products. Females synthesize more iridomyrmecins than males, and the most active (−)-iridomyrmecin is produced by females only. We, therefore, hypothesize that this defense mechanism is used mainly by female wasps when foraging for Drosophila larvae on rotten fruits, but also may protect male wasps during dispersal.