Microorganisms and nematodes in the rhizosphere profoundly impact plant health, and small-molecule signaling is presumed to play a central role in plant rhizosphere interactions. However, the nature of the signals and underlying mechanisms are poorly understood. Here we show that the ascaroside ascr#18, a pheromone secreted by plant-parasitic nematodes, is metabolized by plants to generate chemical signals that repel nematodes and reduce infection. Comparative metabolomics of plant tissues and excretions revealed that ascr#18 is converted into shorter side-chained ascarosides that confer repellency. An Arabidopsis mutant defective in two peroxisomal acyl-CoA oxidases does not metabolize ascr#18 and does not repel nematodes, indicating that plants, like nematodes, employ conserved peroxisomal β-oxidation to edit ascarosides and change their message. Our results suggest that plant-editing of nematode pheromones serves as a defense mechanism that acts in parallel to conventional pattern-triggered immunity, demonstrating that plants may actively manipulate chemical signaling of soil organisms.