The toxic butterfly Heliconius numata, found in forests across South America, mimics the wing patterns of several species of another family of toxic butterflies, Melinaea sp., in order to deter predators more effectively. This example of Müllerian mimicry is under the control of a classic 'supergene', a tight gene cluster usually inherited as a single unit. H. numata is particularly adept at mimicry, able to copy as many as seven different wing patterns. A study of the individual wing-pattern morphs in H. numata shows that different genomic rearrangements at the single supergene P locus tighten the genetic linkage between loci that are otherwise free to recombine in other closely related species. The resulting supergene acts as a simple switch that once thrown, selects which one of a range of complex adaptive phenotypes the butterfly displays. Supergenes are tight clusters of loci that facilitate the co-segregation of adaptive variation, providing integrated control of complex adaptive phenotypes1. Polymorphic supergenes, in which specific combinations of traits are maintained within a single population, were first described for ‘pin’ and ‘thrum’ floral types in Primula1 and Fagopyrum2, but classic examples are also found in insect mimicry3,4,5 and snail morphology6. Understanding the evolutionary mechanisms that generate these co-adapted gene sets, as well as the mode of limiting the production of unfit recombinant forms, remains a substantial challenge7,8,9,10. Here we show that individual wing-pattern morphs in the polymorphic mimetic butterfly Heliconius numata are associated with different genomic rearrangements at the supergene locus P. These rearrangements tighten the genetic linkage between at least two colour-pattern loci that are known to recombine in closely related species9,10,11, with complete suppression of recombination being observed in experimental crosses across a 400-kilobase interval containing at least 18 genes. In natural populations, notable patterns of linkage disequilibrium (LD) are observed across the entire P region. The resulting divergent haplotype clades and inversion breakpoints are found in complete association with wing-pattern morphs. Our results indicate that allelic combinations at known wing-patterning loci have become locked together in a polymorphic rearrangement at the P locus, forming a supergene that acts as a simple switch between complex adaptive phenotypes found in sympatry. These findings highlight how genomic rearrangements can have a central role in the coexistence of adaptive phenotypes involving several genes acting in concert, by locally limiting recombination and gene flow.