Chemical interactions between plants and their insect herbivores provide an excellent opportunity to study the evolution of species interactions on a molecular level. Here, we investigate the molecular evolutionary events that gave rise to a novel detoxifying enzyme (nitrile-specifier protein [NSP]) in the butterfly family Pieridae, previously identified as a coevolutionary key innovation. By generating and sequencing expressed sequence tags, genomic libraries, and screening databases we found NSP to be a member of an insect-specific gene family, which we characterized and named the NSP-like gene family. Members consist of variable tandem repeats, are gut expressed, and are found across Insecta evolving in a dynamic, ongoing birth-death process. In the Lepidoptera, multiple copies of single-domain major allergen genes are present and originate via tandem duplications. Multiple domain genes are found solely within the brassicaceous-feeding Pieridae butterflies, one of them being NSP and another called major allergen (MA). Analyses suggest that NSP and its paralog MA have a unique single-domain evolutionary origin, being formed by intragenic domain duplication followed by tandem whole-gene duplication. Duplicates subsequently experienced a period of relaxed constraint followed by an increase in constraint, perhaps after neofunctionalization. NSP and its ortholog MA are still experiencing high rates of change, reflecting a dynamic evolution consistent with the known role of NSP in plant-insect interactions. Our results provide direct evidence to the hypothesis that gene duplication is one of the driving forces for speciation and adaptation, showing that both within- and whole-gene tandem duplications are a powerful force underlying evolutionary adaptation.