Lima bean, Phaseolus lunatus, is a crop legume that produces the cyanogenic glucosides linamarin and lotaustralin. In the legumes Lotus japonicus and Trifolium repens, the biosynthesis of these two α‐hydroxynitrile glucosides involves cytochrome P450 enzymes of the CYP79 and CYP736 families and a UDP‐glucosyltransferase. Here, we identify CYP79D71 as the first enzyme of the pathway in P. lunatus, producing oximes from valine and isoleucine. A second CYP79 family member, CYP79D72, was shown to catalyze the formation of leucine‐derived oximes, which act as volatile defense compounds in Phaseolus spp. The organization of the biosynthetic genes for cyanogenic glucosides in a gene cluster aided their identification in L. japonicus. In the available genome sequence of P. vulgaris, the gene orthologous to CYP79D71 is adjacent to a member of the CYP83 family. Although P. vulgaris is not cyanogenic, it does produce oximes as volatile defense compounds. We cloned the genes encoding two CYP83s (CYP83E46 and CYP83E47) and a UDP‐glucosyltransferase (UGT85K31) from P. lunatus, and these genes combined form a complete biosynthetic pathway for linamarin and lotaustralin in Lima bean. Within the genus Phaseolus, the occurrence of linamarin and lotaustralin as functional chemical defense compounds appears restricted to species belonging to the closely related Polystachios and Lunatus groups. A preexisting ability to produce volatile oximes and nitriles likely facilitated evolution of cyanogenesis within the Phaseolus genus.