Amygdalin is a cyanogenic glycoside enriched in the tissues of many edible plants, including seeds of stone fruits such as cherry (Prunus avium), peach (Prunus persica), and apple (Malus domestica). These plants biosynthesize amygdalin in defense against herbivore animals, as amygdalin generates poisonous cyanide upon plant tissue destruction.1,2,3,4 Poisonous to many animals, amygdalin-derived cyanide is detoxified by potent enzymes commonly found in bacteria and plants but not most animals.5 Here we show that the nematode C. elegans can detoxify amygdalin by a genetic pathway comprising cysl-1, egl-9, hif-1, and cysl-2. A screen of a natural product library for hypoxia-independent regulators of HIF-1 identifies amygdalin as a potent activator of cysl-2, a HIF-1 transcriptional target that encodes a cyanide detoxification enzyme in C. elegans. As a cysl-2 paralog similarly essential for amygdalin resistance, cysl-1 encodes a protein homologous to cysteine biosynthetic enzymes in bacteria and plants but functionally co-opted in C. elegans. We identify exclusively HIF-activating egl-9 mutations in a cysl-1 suppressor screen and show that cysl-1 confers amygdalin resistance by regulating HIF-1-dependent cysl-2 transcription to protect against amygdalin toxicity. Phylogenetic analysis indicates that cysl-1 and cysl-2 were likely acquired from green algae through horizontal gene transfer (HGT) and functionally co-opted in protection against amygdalin. Since acquisition, these two genes evolved division of labor in a cellular circuit to detect and detoxify cyanide. Thus, algae-to-nematode HGT and subsequent gene function co-option events may facilitate host survival and adaptation to adverse environmental stresses and biogenic toxins.