Fungi of the genus Mortierella occur ubiquitously in soils where they play pivotal roles in carbon cycling, xenobiont degradation, and promoting plant growth. These important fungi are, however, threatened by micropredators such as fungivorous nematodes, and yet little is known about their protective tactics. We report that Mortierella verticillata NRRL 6337 harbors a bacterial endosymbiont that efficiently shields its host from nematode attacks with anthelmintic metabolites. Microscopic investigation and 16S ribosomal DNA analysis revealed that a previously overlooked bacterial symbiont belonging to the genus Mycoavidus dwells in M. verticillata hyphae. Metabolic profiling of the wild-type fungus and a symbiont-free strain obtained by antibiotic treatment as well as genome analyses revealed that highly cytotoxic macrolactones (CJ-12,950 and CJ-13,357, syn. necroxime C and D), initially thought to be metabolites of the soil-inhabiting fungus, are actually biosynthesized by the endosymbiont. According to comparative genomics, the symbiont belongs to a new species (Candidatus Mycoavidus necroximicus) with 12% of its 2.2 Mb genome dedicated to natural product biosynthesis, including the modular polyketide-nonribosomal peptide synthetase for necroxime assembly. Using Caenorhabditis elegans and the fungivorous nematode Aphelenchus avenae as test strains, we show that necroximes exert highly potent anthelmintic activities. Effective host protection was demonstrated in cocultures of nematodes with symbiotic and chemically complemented aposymbiotic fungal strains. Image analysis and mathematical quantification of nematode movement enabled evaluation of the potency. Our work describes a relevant role for endofungal bacteria in protecting fungi against mycophagous nematodes.