Differentiation of secondary metabolite profiles in closely related plant species provides clues for unravelling biosynthetic pathways and regulatory circuits, an area that is still underinvestigated. Cucurbitacins, a group of bitter and highly oxygenated tetracyclic triterpenes, are mainly produced by the plant family Cucurbitaceae. These compounds have similar structures, but differ in their antitumour activities and ecophysiological roles. By comparative analyses of the genomes of cucumber, melon and watermelon, we uncovered conserved syntenic loci encoding metabolic genes for distinct cucurbitacins. Characterization of the cytochrome P450s (CYPs) identified from these loci enabled us to unveil a novel multi-oxidation CYP for the tailoring of the cucurbitacin core skeleton as well as two other CYPs responsible for the key structural variations among cucurbitacins C, B and E. We also discovered a syntenic gene cluster of transcription factors that regulates the tissue-specific biosynthesis of cucurbitacins and may confer the loss of bitterness phenotypes associated with convergent domestication of wild cucurbits. This study illustrates the potential to exploit comparative genomics to identify enzymes and transcription factors that control the biosynthesis of structurally related yet unique natural products.