Naturalists have long wondered how brightly coloured butterflies manage to evade the attention of birds that make a meal of other insects.

New research from British ecologists suggests it is not simply a matter of good luck but instead a visual illusion created by their fluttering wings.

The study by researchers from the universities of Exeter and Essex concluded that the spots and stripes found on many butterfly wings – combined with their dancing flight – scramble a predator’s sense of the insects’ speed and direction.

George Hancock, of the University of Exeter’s Centre for Ecology and Conservation in Cornwall, said very few European butterflies were toxic or unpalatable and they were relatively easy to spot in flight, so they needed something special to stay out of harm’s way.

“The illusions interfere with the predator’s most basic visual targeting system and disrupt the final ballistic attack,” Hancock said. “As a result, birds and other predators often miss.”

George Hancock of Exeter University says swallowtails deploy illusions to scramble a predator’s sense of their speed and direction. Photograph: George Hancock

Jolyon Troscianko, also of the University of Exeter, said: “Butterfly wings deform as they fly, clapping together on the upstroke and peeling apart on the downstroke, so their stripes shift angle and point in different directions as they flap.

“Combined with their unpredictable flight paths, this patterning creates misleading motion illusions, causing a predator to miss entirely or to strike a less vulnerable part of the wing, such as the hindwing or tail.”

The experts compared the mechanism to the “barber pole illusion” – the red and white stripes appear to travel upwards even though the pole is only spinning in place.

The breakthrough came when Troscianko put a slow-motion video of a butterfly flying upwards through a “bird-vision” computer model. It seemed to indicate – wrongly – that the butterfly was moving downwards.

Troscianko said: “First I checked this wasn’t a coding error, that I’d swapped up and down somehow, but then it dawned on me that this would be a perfect way to confuse attacking predators.”

The team looked at hundreds of types of European butterflies and found different patterns created different effects.

Swallowtail butterflies were found to be among the best at using motion confusion. Troscianko said: “They are also thought to be closest to the ancestral butterflies, suggesting motion confusion might have been around right at the point when butterflies evolved away from night-flying moths.

“Swallowtails have little tails trailing from their hindwings that help increase their levels of motion confusion. They are frequently found with their tails missing and beak-shaped holes cut from their wing edges by failed bird attacks. This fits with our modelling that shows how the wing markings should deflect attacks sideways and behind the butterfly’s vital body and inner wing sections.”

The team used a high-speed camera to film butterflies taking off to capture how their patterns behave in flight. To test how patterns might affect attacks, 100 human volunteers acted as “predators”, trying to catch virtual butterflies on a touchscreen. They struggled.

The study found that largely white butterflies also managed to dodge predators. The researchers believe that when in flight they appear to move more quickly than they actually do because of the stark contrast they make with their background – which may put out the timing of strikes from predators.

Troscianko said the discovery could be used to begin to explain how other animals used motion confusion. “We think it is likely to be far more widespread in nature than previously realised, from the flapping wings of birds to the flicking tails of lizards and fish. It opens up an exciting new research avenue.”

The study – Butterfly wing patterns in flight create powerful illusory motion cues – is published in the journal Nature.