First there's shock tinged with disbelief. A moment of wonder follows. Then, a desperate scramble to rack your brains and work out just how you've been had. There's no denying the effects of a good magic trick. From the great escapes of Houdini and the surreal mental trickery of Derren Brown to the conjurors at children's parties, the appeal is universal.

"Magic's been around for a very long time and it improves over time," says Richard Wiseman, a professor of psychology at Hertfordshire University. "What you're looking at when you see a finished piece of magic is a great deal of expertise, and I think psychologists have a lot to learn from that."

But, not content with just enjoying the tricks, psychologists are now using their effects on the mind to work out how we handle the floods of sensory information coming into our brains and process it into a mental picture of the world around us. Magic is a deception, a disruption of that orderly mental picture where things seem to float in mid-air or coins and cards vanish in front of our eyes. Scientists now believe that, by mapping out how our brains are deceived, they could even help to unlock some of the mysteries of consciousness itself.

"Over the last five years, there's been a reawakening as we look at things like change blindness [a failure to see large changes in a visual scene] and at the fact that consciousness is a construction and may even be an illusion," says Wiseman, himself an accomplished magician and member of the Magic Circle. "Now there's a recognition that magicians are doing something very special."

Some of the founders of modern psychology were fascinated by magicians: throughout the 1890s, Alfred Binet, inventor of the modern IQ test, and Max Dessoir wrote about the ways in which magicians used suggestion and misdirected attention to get their illusions to work. In 1896, Joseph Jastrow published articles in Science on the mechanics of some tricks by contemporary master magicians. But, aside from describing what the magicians were doing, they were at a loss to explain why magic tricks had the effects they did on the audience. As a result, interest in studying the psychology of magic faded for nearly a century.

But, as Wiseman says, a renaissance is now in full swing.

Magic is all about convincing others that the impossible has just happened. And that deception is achieved with a high degree of skill and showmanship.

"We're starting to realise that magicians have a lot of implicit knowledge about how we perceive the world around us because they have to deceive us in terms of controlling attention, exploiting the assumptions we make when we do and don't notice a change in our environment," says Wiseman. "There is an enormous amount of really detailed instruction on how to perform magic. People are always blown away by how detailed a description you'll have."

A card trick that lasts four or five minutes, for example, might have 20 pages of detailed text to describe exactly where to look, what to say, what to do and so on. And a lot of the understanding of a trick has to be from the perspective of the audience.

While the magician's dexterity is important, the audience is also a vital participant in the deception. After all, it is in their minds that the illusion is created. "Magicians seem to be able to carry out secret actions in front of their audience without being spotted. I'm interested in why people don't perceive those actions," says Gustav Kuhn, a psychologist at Durham University.

A simple example of misdirection is used in the coin drop trick. "What you're doing there is pretending to take the coin from one hand to the other but, in fact, leaving it in the original hand," says Wiseman. "What's important is that you're looking where you want the audience to look. You're not looking at the coin, you're looking at the empty hand. In terms of movement, you're moving the hand that doesn't contain the coin to attract people's attention over to that hand."

Another trick, where a magician pretends to throw a ball up in the air, takes the misdirection a step further. "People often experience the ball moving up in the air even though there is no ball present," says Kuhn. They claim to see a ball moving but obviously it's not there so it must be in their mind."

Psychologists can use these tricks to catch a glimpse into how our minds interpret the world around us.

"Magicians are manipulating your consciousness. They are showing you something impossible," says Wiseman. "They're getting you to construct a narrative, which simply isn't true. So that means they know how to make you aware of certain things and blind to other things. What I'm hoping is that magic, this entertainment vehicle that has been around for a long time, will give us a real insight into the deep mysteries of consciousness."

Our brains filter out a huge amount of the mass of sensory input flooding in from our environment. Kuhn explains that we see what we expect to see and what our brains are interested in. "Our visual representation of the world is much more impoverished than we would assume. People can be looking at something without being aware of it. Perception doesn't just involve looking at an object but attending to it."

In Kuhn's recent work, he performed a trick where a cigarette seems to disappear. It involved no sleight of hand or secret. It was a simple case of dropping the cigarette into his lap. "It happens right in front of the spectator's eyes but I misdirect their attention away from the cigarette," says Kuhn.

While his spectators watched, they wore eye trackers (essentially a couple of cameras that monitor eye movement and provide an exact location of where a person is looking in a scene).

It is known that we only receive high-quality information from the area we are fixated on, right in the centre of our field of view. If you stretch out your arm, it is about two thumbs' width at the centre of your vision - everything else is pretty much blurred. The way we compensate for this is to move our eyes around to fill in the gaps and create a better picture of the world around us.

Kuhn's results, to be published in the journal Perception in the next few months, showed that simply staring at the location of the deception was not enough for people to discover how the trick happened.

"People could be looking very close to where the cigarette was being dropped without even seeing it," he says. "Other people were looking quite far away but they did actually did spot the cigarette."

"What it shows is just how much of the picture in our head of our surroundings is a massive construction, based on expectations, what we think is important, what we normally encounter and so on," says Wiseman. "And that's what magicians are very good at exploiting."

Misdirection of an audience, therefore, depends on more than just making people look the wrong way - the truly successful magician misdirects attention. Often, attention is focused on where a person is looking, but this can be manipulated. "You might be looking at a scene and then you hear a voice from the back so your attention is moved towards the back and your processing of visual information will be impaired at the front," says Kuhn.

Verbal suggestion can also play a big role in misdirection. In a recent study, Wiseman looked at how the classic metal-bending tricks, employed by magicians the world over and perhaps made most famous by Uri Geller, used verbal cues. In his experiment, he showed a group of students a video of a trick where a magician bends a key, apparently using his psychokinetic ability (in fact, the bending was done by sleight of hand). The magician then placed the key on a table and the video ended with a static shot of the bent key, which did not bend any further. But a voiceover from the magician at this stage suggested that the key was indeed continuing to bend.

The results, published this year in the British Journal of Psychology, showed that 40% of people claimed to see the key continuing to bend during the static shot at the end of the video. In the control group, where there was no voiceover from the magician, only 5% reported that they saw the key continuing to bend.

Of course, suggestion can take other forms.

"With the ball experiment, we discovered that people aren't just looking up at the ball, they're looking at facial clues to judge where the ball is going to end up," says Kuhn. "If the magician doesn't look up in the air, the trick doesn't work. People feel that they're watching the ball but what they are doing is monitoring the magician's face and cues and using that information to guide their eye movements."

This leads to an interesting idea -could some people be immune to some of the effects of magic? People who suffer from autism, for example, tend to have difficulties gauging facial cues, so their attention is less influenced by where somebody is looking. "You'd expect that somebody who suffered from autism would be more likely to spot the cigarette trick," agrees Kuhn.

The next step is to look at the brain directly. Working with psychologists Tim Hodson and Ben Parris at Exeter University's Centre for Cognitive Neuroscience, Kuhn plans to put people in functional magnetic resonance imaging machines to study which parts of the brain activate when they watch magic tricks.

"We're very interested in the part of the brain that detects cause and effect relations," says Parris.

In particular, the experiments will monitor the dorsal lateral pre-frontal cortex, which is known to be the bit of the brain that registers surprise, and the anterior cingulate, which is activated whenever something incongruous happens in our immediate environment.

Of course, magic is more than just surprise, so the researchers will be looking for something more. "When you're watching magic, there is just a split second when you're in disbelief and that's what we're looking for, that exact moment," he says. "The magic spot."

"No one's done this and it's unclear whether it'll be a single part of the brain or a network," says Parris.

But while psychologists slowly get to grips with the way magicians manage to trick our brains, is there not a risk that the magic will lose its power? That it will cease to be amazing? Wiseman thinks not. "What we get is a more informed audience," he says. "It's a little bit like juggling - you appreciate the juggler more once you've tried to juggle three balls and then you suddenly realise how hard it is to juggle seven."

The research will have benefits for the practitioners of magic, too. "What they will realise is that the human mind is a lot more fallible than we magicians expect," says Kuhn. "Maybe magicians are too careful in the way they conceal their secrets in front of an audience. They can probably get away with quite a bit more."