The wing patterns of butterflies and moths (Lepidoptera) are diverse and striking examples of evolutionary diversification by natural selection1,2. Lepidopteran wing colour patterns are a key innovation, consisting of arrays of coloured scales. We still lack a general understanding of how these patterns are controlled and whether this control shows any commonality across the 160,000 moth and 17,000 butterfly species. Here, we use fine-scale mapping with population genomics and gene expression analyses to identify a gene,cortex, that regulates pattern switches in multiple species across the mimetic radiation inHeliconiusbutterflies.cortexbelongs to a fast-evolving subfamily of the otherwise highly conserved fizzy family of cell-cycle regulators3, suggesting that it probably regulates pigmentation patterning by regulating scale cell development. In parallel with findings in the peppered moth (Biston betularia)4, our results suggest that this mechanism is common within Lepidoptera and thatcortexhas become a major target for natural selection acting on colour and pattern variation in this group of insects.