For the first time, scientists have discovered how a species of butterfly mimics other species to avoid being eaten by birds, unlocking clues to a mystery that has puzzled scientists since Darwin.

The research, published in Nature on August 14, finds that a "supergene" - a cluster of genes that controls the wing pattern - allows the Amazonian butterfly Heliconius numata to take on the appearance of poisonous species to confuse predators.

According to the study, the Amazonian butterfly's wing pattern in French Guiana differs drastically from its counterparts in Peru. Though they're the same species with the same DNA, both look more like the local butterflies that birds have learned to avoid eating.

Researchers, led by the Muséum National d'Histoire Naturelle in Paris and the University of Exeter, show how butterflies perform this amazing trick, known as "Müllerian mimicry," where two or more distasteful species with similar predators share the same warning marks.

In Müllerian mimicry, predators learn from an unpleasant past experience and avoid eating any similar looking creatures in the future.

"This phenomenon has puzzled scientists for centuries, including Darwin himself," Professor Richard French-Constant, from the University of Exeter, told the Independent.

"Indeed, it was the original observations of mimicry that helped frame the concept of natural selection," he added.

The scientists in the recent study set out to determine how successful color combinations arose in the first place and if the mutation that results in one species adopting the warning coloration of another species occurs in a single step, or is the result of incremental change in the population.

They found that the mechanism responsible for producing variation is contained in a single region of the chromosome.

"This supergene is a kind of switch that holds several mimicry factors together," Dr Siu Fai Lee from the Department of Genetics and Bio21 Institute at the University of Melbourne told ABC. He was part of the international research team.

"DNA along this chromosome flips to produce different combinations of the supergene, allowing the butterfly to morph into different forms. It allows mimicry factors that work best together to stay together, while preventing combinations that produce other patterns from continuing in the population," he added.

Several complex patterns in nature are controlled by supergenes, like the shape of primrose flowers and the pattern of snail shells.

The discovery proves that small chromosomal changes can preserve successful gene combinations and thus help a species to adapt.