The potato cyst nematode (PCN) causes extensive crop losses worldwide. Because the hatching of PCN requires host-derived molecules known as hatching factors (HFs), regulating HF production in host plants may help to control this harmful pest. Solanoeclepin A (SEA), isolated from potato, is the most active HF for PCN; however, its biosynthesis is completely unknown. We discovered a HF called solanoeclepin B (SEB) from potato and tomato root exudates and showed that SEB was biosynthesized in the plant and converted to SEA outside the plant by biotic agents. Moreover, we identified five SEB biosynthetic genes encoding three 2-oxoglutarate-dependent dioxygenases and two cytochrome P450 monooxygenases in tomato. Exudates from tomato hairy roots in which each of the genes was disrupted contained no SEB and had low hatch-stimulating activity for PCN. These findings will help to breed crops with a lower risk of PCN infection.