Root-knot nematodes (Meloidogyne spp.) have garnered significant attention from researchers owing to the substantial damage they cause to crops and their worldwide distribution. However, controlling these nematodes is challenging because a limited number of chemical pesticides and biocontrol agents are effective against them. Here, we demonstrate that pepper rotation markedly reduces Meloidogyne incognita infection in cucumber and diminishes the presence of p-hydroxybenzoic acid in the soil, a compound known to exacerbate M. incognita infection. Pepper rotation also restructures the rhizobacterial community, leading to the colonization of the cucumber rhizosphere by two Pseudarthrobacter oxydans strains (RH60 and RH97), facilitated by enrichment of palmitic acid in pepper root exudates. Both strains exhibit high nematocidal activity against M. incognita and have the ability to biosynthesize indoleacetic acid and biodegrade p-hydroxybenzoic acid. RH60 and RH97 also induce systemic resistance in cucumber plants and promote their growth. These data suggest that the pepper root exudate palmitic acid alleviates M. incognita infection by recruiting beneficial P. oxydans to the cucumber rhizosphere. Our analyses identify a novel chemical component in root exudates and reveal its pivotal role in crop rotation for disease control, providing intriguing insights into the keystone function of root exudates in plant protection against root-knot nematode infection.