The complete metabolic pathway for the biosynthesis of the psychedelic compound mescaline in the peyote cactus has been deciphered. This discovery suggests that biotechnological strategies could be developed to produce mescaline sustainably, addressing limitations in current knowledge of how medicinal compounds are made in plants.