Waking up in the middle of the night to find your body frozen and pinned down by an invisible weight is the stuff that ghost stories are made of. Sure enough, a range of cultures have folded sleep paralysis into their horror lore — Americans did so recently in the 2016 horror film Dead Awake — suggesting that this recurring nightmare isn’t specific to any one time or place. Scientists studying the terrifying phenomenon think that it’s actually a neurologically driven process — rather, one that goes awry, suggesting there’s no escaping it unless we intervene directly in our heads.

Until science illuminated the origin of this disturbing nightmare, humans assumed it had a supernatural source. In places as varied as Scandinavia, Newfoundland, Korea, the American South, and Turkey, folklore blames the experience on some kind of evil spirit, witch, or creature that sits on a person’s chest or holds them down while they sleep. Now we know that what people have blamed on the Night Hag for so many centuries is actually the result of the sleep cycle going wrong (sorry, Night Hag).

You probably don’t realize it, but you’re actually physically paralyzed while you sleep for a big chunk of the night, which scientists in the Journal of Neuroscience blamed on the tandem work of the neurotransmitters GABA and glycine in 2011. This state is known as “muscle atonia,” and it only happens during rapid eye movement (REM) sleep — the deepest part of the sleep cycle that produces the most vivid dreams. It’s thought that we evolved this temporary paralysis because otherwise we might act out our dreams more than we already do, which could be very dangerous. During REM sleep, which happens in periods lasting 90 to 120 minutes, your breathing also becomes faster and highly irregular. It’s not a great part of the sleep cycle to interrupt.

sleep paralysis
John Henry Fuseli's 'The Nightmare' depicts the night hag on a sleeping woman's chest.

Unfortunately, poor sleep habits, exhaustion, shift work, and jet lag can shake you awake during REM sleep, according to researchers at the Anomalistic Psychology Research Unit, Goldsmiths, at the University of London. When you’re in the groggy, half-awake state — quickly waking up from REM sleep is notoriously difficult — breathing feels laborious because it’s been happening at an irregular pace, and you’re keenly aware that you can’t move. As panic sets in, it only exacerbates the feeling that you can’t breathe.

To make matters worse, studies have shown that hallucinations often accompany the physical terror. In 2011 in the journal Sleep Medicine Reviews, researchers combed through 35 studies on sleep paralysis from the past 50 years and grouped the hallucinations into three horrific types: “The presence of an intruder, pressure on the chest sometimes accompanied by physical and/or sexual assault experiences and levitation or out-of-body experiences.” Researchers think these hallucinations are a remnant of the dream state, though it’s not clear why these three types are the most common.

Luckily, the sensation passes as you ease out of the dream state, and it’s not thought to cause any long-term harm, at least physically. Psychologically, though, sleep paralysis can mess with your head long after you get out of bed. In 2013, a study in Clinical Psychological Science looked at the types of distress people experienced after having an episode and found that that the effects include sensing unseen presences, feeling like death is imminent, having a heightened fear of threat or assault, and generally ruminating on the episode, though the type of distress that ensues depends on the details of the experience. People who had particularly sense-based experiences — like straight-up seeing and feeling a demon crouched on your chest — tended to have more physical distress later. The effects are bad enough that the researchers say sleep paralysis could “make a significant contribution to the billions of dollars, worldwide, in costs associated with accidents, illnesses, and lost productivity associated with sleep disturbances.

Even if you’re one of the 92 percent of the general population that doesn’t experience sleep paralysis, you’ll never fully escape their influence. The word “nightmare” was actually first coined to describe sleep paralysis, folding in the Old English word mare — which refers to the mythological incubi, demonic sleep-molesters that were more than willing to crush a dreamer’s lungs.