Underground microbial ecosystems have profound impacts on plant health1-5. Recently, essential roles have been shown for plant specialized metabolites in shaping the rhizosphere microbiome6-9. However, the potential mechanisms underlying the root-to-soil delivery of these metabolites remain to be elucidated10. Cucurbitacins, the characteristic bitter triterpenoids in cucurbit plants (such as melon and watermelon), are synthesized by operon-like gene clusters11. Here we report two Multidrug and Toxic Compound Extrusion (MATE) proteins involved in the transport of their respective cucurbitacins, a process co-regulated with cucurbitacin biosynthesis. We further show that the transport of cucurbitacin B from the roots of melon into the soil modulates the rhizosphere microbiome by selectively enriching for two bacterial genera, Enterobacter and Bacillus, and we demonstrate that this, in turn, leads to robust resistance against the soil-borne wilt fungal pathogen, Fusarium oxysporum. Our study offers insights into how transporters for specialized metabolites manipulate the rhizosphere microbiota and thereby affect crop fitness.