Curl up by the fire and I'll tell you a ghost story. Don't be alarmed by the creak of the floorboards, the murmurs in the basement, the shrill ululations of a distant dog. Try not to be perturbed by the flickering candle, the fleeting shadows, the horned, hairy hand that appears at your elbow. Something moved? There's a face in the brickwork? A murderer, long ago, was buried in the cellar? Stay calm. Breathe deeply. The ghosts of Christmases past are gathering.

It was the Victorian era, of course, when ghosts proliferated most obviously in fiction – as well as on stage, in photographs and in drawing room seances. Before the start of Victoria's reign in 1837, the health of the genre was thought to be failing. But by 1887, when Mary Louise Molesworth wrote The Story of the Rippling Train, her character Mrs Snowdon was bemoaning ghosts' prevalence. "One hears nothing else nowadays," she said, and in the pages that followed, she would hear yet another, about the phantom of a beautiful woman who had appeared after being terribly burnt in a fire.

What had raised all these apparitions from the dead? The most straightforward explanation is the rise of the periodical press, says Ruth Robbins, professor of English literature at Leeds Metropolitan University. Ghost stories had traditionally been an oral form, but publishers suddenly needed a mass of content, and ghost stories fitted the bill – short, cheap, generic, repetitive, able to be cut quite easily to length.

Reading on mobile? Watch Ruth Robbins discussing Victorian ghost stories

Ever one to spot a commercial opportunity, she says, Charles Dickens produced his own highly successful ghost story, A Christmas Carol, in serial form just before Christmas 1843. This was the same year the first commercially produced Christmas card was sent, and Dickens's story both reflected and influenced a growing trend for marking Christmas with secular celebrations. Dr Andrew Smith, author of The Ghost Story 1840-1920, says: "People like Dickens wanted to revive some notion of community invested within that idea of Christmas. What's interesting about his version of Christmas is that it's not particularly Christian. It's about the family, helping the poor, a moment where you might pause and reflect on your life." It's about Ebenezer Scrooge realising, through the counsel of ghosts, that he must embrace his family, look after his good-natured clerk, and become the embodiment of generosity.

Christmas has long been associated with ghosts, says Roger Clarke, author of A Natural History of Ghosts: 500 Years of Hunting for Proof. Just before Christmas 1642, for instance, shepherds were said to have seen ghostly civil war soldiers battling in the skies. This connection continued in the Victorian era through Dickens's story, and through the ghost stories he later published at Christmas in his periodical All the Year Round, with contributors including Wilkie Collins and Elizabeth Gaskell. It would also continue in the tradition started by MR James, the provost of King's College, Cambridge, who would invite a select few students and friends to his rooms each year on Christmas Eve, where he'd read one of the ghost stories he had written, which are still popular today. They include Canon Alberic's Scrap-Book (1895), in which an ancient holy book brings forth a demonic presence, first announced by a hand covered in "coarse black hairs, longer than ever grew on a human hand; nails rising from the ends of the fingers and curving sharply down and forward, grey, horny and wrinkled".

The popularity of ghost stories was strongly related to economic changes. The industrial revolution had led people to migrate from rural villages into towns and cities, and created a new middle class. They moved into houses that often had servants, says Clarke, many taken on around October or November, when the nights were drawing in early – and new staff found themselves "in a completely foreign house, seeing things everywhere, jumping at every creak". Robbins says servants were "expected to be seen and not heard – actually, probably not even seen, to be honest. If you go to a stately home like Harewood House, you see the concealed doorways and servant's corridors. You would actually have people popping in and out without you really knowing they were there, which could be quite a freaky experience. You've got these ghostly figures who actually inhabit the house."

Lighting was often provided by gas lamps, which have also been implicated in the rise of the ghost story; the carbon monoxide they emitted could provoke hallucinations. And there was a preponderance of people encountering ghosts in their daily life come the middle of the century. In 1848, the young Fox sisters of New York heard a series of tappings, a spirit apparently communicating with them through code, and their story spread quickly. The vogue for spiritualism was under way. Spiritualists believed spirits residing in the afterlife were potentially able to commune with the living, and they set up seances to enable this.

Peter Lamont, author of Extraordinary Beliefs, says these gatherings started off quite simply, "and the phenomenon gets more and more impressive. There are floating tables, floating musical instruments, and at some point you get full-form materialisation of ghosts, dressed in white. Occasionally, the [apparition] would get grabbed at a seance and it was discovered that it was actually the medium."

This interest in the supernatural might seem at odds with the growing body of scientific and technological knowledge, but many argue they were intimately connected. In the 19th century, people were increasingly able to communicate at a distance, in disembodied fashion. The telegraph allowed messages to be tapped out in code over long distances – not so unlike the Fox sisters' purported ghost – and the ability to communicate first with other cities, then countries, eventually to transmit messages across the Atlantic, was brilliant and alarming. "If you can have people communicating from 3,000 miles away," says Robbins, "words coming across the ocean, tapped out in Morse code, it may actually be quite a small leap of the imagination to say, 'There's a dead person who I used to know quite well who is talking to me through Morse code.'"

An 1860s picture of a woman getting a scare from an 'apparition'. Photograph: Hulton Archive/Getty Images

The growth of photography brought the advent of spirit photography – there were people who charged enormous fees, and used various tricks, to picture sitters with ghostly images of dead loved ones. William Mumler, for instance, who created a famous image of Mary Todd Lincoln with the ghostly hands of her dead husband, Abraham Lincoln, resting on her shoulders. Then came film and radio. Ghostly disembodied voices and images poured out of the screen and over the airwaves.

There were ghosts in the ether, under the bed, and more and more, in people's heads. "Throughout the 19th century," says Smith, "there is a progressive internalisation of horror, the idea that the monsters are not out there, but to be found within. That obviously culminates with Freud. With the ghost story there's a sense that instead of being able to lock yourself away in your home, to leave the monster outside, the monster lives with you, and has a kind of intimacy."

Merry Christmas – and sleep soundly.

What's your favourite ghost story? Let us know below