Since Charles Darwin, biologists have pondered the mystery of "mimicry butterflies", which survive by copying the wing patterns of other butterflies that taste horrible to their predators, birds.
The answer, according to a study released on Friday, lies in an astonishing cluster of about 30 genes in a single chromosome.
"We were blown away by what we found," said Mathieu Joron of France's National Museum of Natural History, who led the probe into what is being called a "supergene".
"These butterflies are the 'transformers' of the insect world," said Joron.
"But instead of being able to turn from a car into a robot with the flick of a switch, a single genetic switch allows these insects to morph into several different mimetic forms.
"It is amazing, and the stuff of science fiction. Now we are starting to understand how this switch can have such a pervasive effect."
The trick, known as Muellerian mimicry, was investigated by French and British scientists, who focussed on a species of Amazonian rainforest butterfly, Heliconius numata.
It is able to copy the colour patterns of several species of the Melinaea butterfly which are unpalatable to birds.
The "supergene" comprises a tightly packed region of genes on a single chromosome which control different elements of the wing pattern.
"By changing just one gene, the butterfly is able to fool its predators," explained Richard ffrench-Constant of the University of Exeter, southwestern England.
Even more astonishing is that three versions of the chromosome exist within this species, with each version controlling distinct wing-pattern forms.
Even though the butterflies look quite different from each other, they have the same DNA.
The supergene apparently transmits in a block from generation to generation, rather than go through recombination -- the mingling of genes from both parents.
The "supergene" also appears important in other species, say the authors.
One such species, the peppered moth, developped black wings in 19th-century Britain as a means of gaining camouflage in the sooty industrial environment.
"It's a gene that really packs an evolutionary punch," said ffrench-Constant.
The paper is published online by the British science journal Nature.
Explore further: Pollen on birds shows feeding grounds