Several insect lineages have developed diverse strategies to sequester toxic pyrrolizidine alkaloids from food-plants for their own defense. Here, we show that in two highly divergent insect taxa, the hemimetabolous grasshoppers and the holometabolous butterflies, an almost identical strategy evolved independently for safe accumulation of pyrrolizidine alkaloids. This strategy involves a pyrrolizidine alkaloid N-oxygenase that transfers the pyrrolizidine alkaloids to their respective N-oxide, enabling the insects to avoid high concentrations of toxic pyrrolizidine alkaloids in the hemolymph. We have identified a pyrrolizidine alkaloid N-oxygenase, which is a flavin-dependent monooxygenase, of the grasshopper Zonocerus variegatus. After heterologous expression in E. coli, this enzyme shows high specificity for pyrrolizidine alkaloids of various structural types and for the tropane alkaloid atropine as substrates, a property that has been described previously for a pyrrolizidine alkaloid N-oxygenase of the arctiid moth Grammia geneura. Phylogenetic analyses of insect flavin-dependent monooxygenase sequences suggest that independent gene duplication events preceded the establishment of this specific enzyme in the lineages of the grasshoppers and of arctiid moths. Two further flavin-dependent monooxygenase sequences have been identified from Z. variegatus sharing amino acid identities of approximately 78% to the pyrrolizidine alkaloid N-oxygenase. After heterologous expression, both enzymes are also able to catalyze the N-oxygenation of pyrrolizidine alkaloids, albeit with a 400-fold lower specific activity. With respect to the high sequence identity between the three Z. variegatus sequences this ability to N-oxygenize pyrrolizidine alkaloids is interpreted as a relict of a former bifunctional ancestor gene of which one of the gene copies optimized this activity for the specific adaptation to pyrrolizidine alkaloid containing food plants.