The first time Tim Brown saw the Hat Man, he was 14 years old and curled up in his bed in Nashville, Tennessee. He was dozing, with the only light in the room coming from the flicker of late-night television. As he drifted off to sleep, a sound from the television shook him back awake.

And that’s when he saw him. The dark figure of a man, as featureless as the shadows where he stood. He was tall. He wore a broad-brimmed hat and a trench coat. He didn’t say a word. He didn’t need to. The fear sucked the breath from Brown’s chest, rendering him mute and immobile. The man lingered just outside the frame of Brown’s bedroom door, flickering in the shadows between the hallway and his grandmother’s room. Finally, as if breaking a spell cast over him, Brown threw himself from his bed screaming and ran into the hallway for a fight.

But the man was gone.

Still haunted by the vision more than a decade later, in 2008, Brown posted his story on a blog he called The Hat Man Project and encouraged others to share as well. (Quartz’s attempts to reach Brown for comment were unsuccessful.) He also scoured the internet, and found more posts on forums and blogs describing similar encounters.

The global anthology of Hat Man stories has only grown since. The shape of the frightening figure occasionally varies, but the way he makes his victims feel never does: utterly paralyzed with terror, and breathless, as if fear had frozen them from the inside out.

The Hat Man has been the subject of documentaries and seems to have inspired one of the more chilling ghosts in the Netflix horror show The Haunting of Hill House. Otherwise sober-minded people report having woken from their dreams to see the figure. Some dismiss him as a bad dream or a neurological quirk; others feel in his presence something much more sinister and otherworldly.

But if the Hat Man is just a nightmare, how did the whole world start having the same bad dream at once?

Shared nightmares

Shelley Adler, a medical anthropologist at the University of California, San Francisco, had a similar question. Adler became interested in the cultural origins of nightmares after reading about the deaths of several ethnic Hmong refugees who emigrated to the US from Laos.

In four years spanning the late 1970s and early 1980s, 18 seemingly healthy Hmong men living in the US perished suddenly in their sleep. Almost 100 more deaths followed in the next decade before tapering off.

Doctors ascribed the deaths to a condition with the alarming name of “sudden unexpected/unexplained nocturnal death syndrome,” or SUNDS. In the years since, researchers have theorized that many SUNDS deaths are caused by Brugada syndrome, a genetic condition more common in people of Southeast Asian descent that causes irregular heartbeats and increases the risk of sudden death.

But in the Philippines, Thailand, Laos, and other places where such deaths were slightly more common, SUNDS had a different name that often translated as some variation of “nightmare” or “nightmare death syndrome.”

The name suggested that it was the dream itself that killed people, a sort of real-life version of Nightmare on Elm Street, the horror flick in which people murdered in their dreams by the blade-fingered Freddy Krueger died in real life, too.

In an effort to understand Hmong interpretations of these deaths, Adler interviewed Hmong refugees living in Stockton, California. When asked about common nightmares, men and women described a figure called dab tsog (pronounced “da cho”), an evil spirit that visited sleepers at night, pressed upon their chests, and attempted to smother them as they slept. Almost all of the interviewees were familiar with dab tsog; 58% reported having been visited by the nightmare themselves.

But the Hmong were hardly the first or the only people to have an oral record of such suffocating night-time visitors, as Adler describes in her book, Sleep Paralysis: Night-mares, Nocebos, and the Mind-body Connection.

For about as long as written records have existed, people have described a frightening night-time vision that paralyzes them with fear and seems to suck the breath right out of them, often by pressing directly upon their chest. Tales of such evil spirits come from ancient Assyria and Greece. Among the Canadian Inuit, the word uqumangirniq described this awake-but-paralyzed feeling; in Japan, kanashibari. Folklore from Newfoundland describes an old hag who sits upon sufferers’ chests as they sleep.

“The entity has stalked human beings throughout history, not merely within a particular society or during a specific time,” Adler wrote. The appearance of the figures that people saw in these frightening episodes, if they saw anything at all, varied across culture. But the fear was always the same.

Sleep science

Until relatively recently, people who experienced these night frights had little choice but to ascribe them to culturally available explanations: demons, ghosts, spirits, indigestion, madness. But by the late 20th century, science offered a new explanation, one rooted in biology: sleep paralysis.

People who wake in the night and feel paralyzed with terror aren’t crazy or imagining things. During the rapid eye movement (REM) stage of sleep, the muscles relax to the point where they become immobilized, probably to keep us from violently acting out our dreams when we sleep. This is also the stage of the most intense dreams. People who experience sleep paralysis have essentially woken up before they’ve stopped dreaming.

It’s an incredibly common sleep problem. An estimated 8% of people experience it regularly, and some estimates have placed the number of people who have at least one experience of it in their lifetimes as high as 40%.

Many who experience sleep paralysis also experience hypnagogic hallucinations: vivid images perceived in the transition from wakefulness to sleep, or the other way around. Spiders or insects crawling up the walls is a particularly common such vision, according to Alon Avidan, a professor of neurology at the University of California Los Angeles and director of the UCLA Sleep Disorders Center. So are human-shaped figures. These episodes are often accompanied by a profound sense of fear and anxiety, and a sense that something is trying to harm the sleeper.

“What they’re seeing is very real to them, and they’re reacting to the image in a way that seems to be very similar across individuals, across cultures, and across geographies,” Avidan said.

Stress, caffeine, and sleep deprivation can all make these episodes more frequent and intense, he said. Reports of such episodes from patients at the UCLA clinic—many of whom are university students—tend to spike during finals and midterms.

The stuff that dreams are made of

Sleep science can’t yet explain why the brain serves up the specific images it does in dreams, Avidan said—nor why multiple people across cultures might experience the same dream (or nightmare).

We’re also not always conscious of the ways in which images in popular culture influence dreams and memories. Memory is a fluid and easily manipulated thing, and it’s not uncommon for people to have memories that feel entirely real, without being aware of the role that outside factors may have played in their creation.

The fluidity of memory can lead to new cultural myths. In 1961, a US couple named Betty and Barney Hill arrived home from a road trip tired, disheveled, and unable to account for the previous few hours. Two years later, under hypnosis in a psychiatrist’s office, the couple reported that they’d been abducted by aliens during the journey—something never before reported, though it had recently been a plotline on the popular sci-fi television show The Outer Limits. Barney Hill described a bug-eyed creature that closely resembled the alien on that show.

Media reports then publicized the Hills’ version. In the two years after NBC aired a 1975 TV movie about the couple’s experience, reports of alien abductions—a thing never recorded in human history before Betty and Barney Hill—rose 2,500%.

At the time of their infamous drive, the Hills were stressed and sleep-deprived, both of which can contribute to false memory formation. By all contemporary accounts, they were upright citizens who truly believed that this abduction happened to them. They probably weren’t aware that the portrayal of extraterrestrials in popular culture might have influenced their own memories.

When faced with the unknown, humans tend to reach for the closest culturally available explanation. If you can’t account for time and have long been interested in contact with aliens, as Betty Hill was, then an alien abduction might seem like a possible answer. If you wake up afraid and breathless at night, and you live in a society where more than half of the people you know have reported having an evil spirit sit upon their chests as they sleep, an evil spirit is a logical explanation for your own experience. The more people report such experiences, the easier they are to accept.

In contemporary US society, Adler wrote, the primary disseminator of these experiences is the internet. “People who have night-mares outside of a cultural framework of understanding draw upon a contemporary narrative in interpreting their experiences—such as one derived from medicine or psychiatry (for example, heart disease or mental illness), religion (demons), or the paranormal (including alien abductions),” she wrote.

Christopher French, a psychology professor at Goldsmiths, University of London, thinks something very similar is happening with sleep paralysis and the Hat Man. In sleep paralysis, “you’re in this weird kind of hybrid state, a mix of normal waking consciousness and dream consciousness. You know you can’t move. You can see that you’re in your bedroom. So it feels very, very real,” French said.

“When I sat and thought about [the Hat Man], the thing that came to my mind was Freddy Krueger,” he continued. “This notion that you can be attacked when you’re asleep, that’s when you’re vulnerable. And of course, Krueger wears a hat.”

The horror film Nightmare on Elm Street came out in 1984. In it, a terrifying man in a broad-brimmed hat attacks victims in their beds. Freddy Krueger’s distinctive silhouette become an iconic symbol of fear for a generation. It’s possible that Krueger has infiltrated some of our nightmares—and that by sharing our stories on the internet, we are creating the stuff of others’ nightmares too.

Quartz News is a weekly video series bringing you in-depth reporting from around the world. Each episode investigates one story, breaking down the often unseen economic and technological forces shaping our future.

Click here for previous stories.