To understand the literary gothic—to even begin to account for its curious appeal, and its simultaneous qualities of seduction and repulsion—it is necessary to undertake a little time travel. We must go back beyond the builders putting the capstone on Pugin’s Palace of Westminster, and on past the last lick of paint on the iced cake of Horace Walpole’s Strawberry Hill House; back again another six hundred years past the rap of the stone-mason’s hammer on the cathedral at Reims, in order to finally alight on a promontory above the city of Rome in 410 A.D. The city is on fire. There are bodies in the streets and barbarians at the gates. Pope Innocent I, hedging his bets, has consented to a little pagan worship that is being undertaken in private. Over in Bethlehem, St Jerome hears that Rome has fallen. “The city which had taken the whole world,” he writes, “was itself taken.” The old order—of decency and lawfulness meted out with repressive colonial cruelty—has gone. The Goths have taken the Forum.

The term gothic was first used as an insult, and writers of the genre have always had a reckless disregard for either praise or blame. At first, however, the insult was leveled not at a work of literature, but at the brutally ornate architecture of gargoyles and buttresses which distinguish the great cathedrals of the medieval age. During the renaissance, Giorgio Vasari—an Italian scholar with a taste for the white facades and polite proportions of Classical architecture—found himself within a vaulted cathedral, and was appalled. It was, he said, all confusion and disorder, a “deformed malediction” that “polluted the world.” It was as barbarous an act of social and aesthetic rebellion as the work of the Germanic tribes that tore down the last of the Roman Empire. It was, in fact, Gothic.

In 1764, when Horace Walpole published The Castle of Otranto—a slim, absurd novel that mingles romantic fantasy with violence and transgression—he subtitled his work “a Gothic story.” He knew what he was about. The reader would not encounter in those pages the moral rigor of Daniel Defoe, or the psychological realism of Samuel Richardson. They would find instead a vast plumed helmet that appears out of the blue to crush a young suitor, followed by a hysteric procession of ghosts, cruelties, lusts, improbable vanishings and labyrinthine pursuits. Its effects were like those of the cathedrals: too large, too impolite, too ill-mannered; seeming both to enlarge the reader’s imagination and to speak to their most concealed and furtive desires.

Walpole, perhaps lacking the courage to reveal that the novel had come entirely from his own imagination, published it under the guise of a real manuscript by a certain Onuphrio Muralto, Canon of St Nicholas at Otranto, and translated by an English scholar. It was an instant hit. Bolstered by praise, Walpole revealed that the work was a fiction. The critics began to sharpen their knives. Lusts of the flesh, murderous villains and supernatural entities: those were almost to be expected from an Italian curate. But they were not at all fit for the mind of a decent Englishman. Still, the spark in the crypt had been struck, and the new gothic fashion found an avid readership. In 1797 an anonymous essayist (probably alarmed by the publication of Matthew Lewis’s The Monk, in which a charismatic man of God descends into the most gleefully wicked acts of desire and sin) wrote on an essay titled “Terrorist Novel Writing.” In it, the writer lamented that the gothic exposed its readers to “such a confusion of terrors that it must be hurtful.”

Still: it is typical of the gothic that it repels and appeals in equally fervent measure. Critics and commentators keen on preserving decorum recoiled; but anyone with a taste for the anarchic was drawn in. After all, the Goths and the Visigoths rebelling against Rome had been freedom fighters. It’s telling that the gothic novel found its foothold in England just as the French Revolution was harvesting aristocratic heads in baskets. Why not read a novel that, like The Monk, concludes with a tinselly avenging angel descending from the heavens as if on puppet strings? Stranger things were happening across the channel. Whether the shadow of the guillotine chilled or thrilled (and it did thrill: Burke wrote of the French Revolution that it was “the most astonishing thing that had happened in the world”), a gothic novel would offer a consoling affirmation.

The gothic has adapted and grown, like a stone grotesque acquiring moss, though it has never departed from its underlying principles. Edmund Burke in his essay on the sublime identified what it was that Vasari felt, and what it was that so seduced the readers of Matthew Lewis and Anne Radcliffe: the idea that terror, and terrible things, could excite the emotions in the way the sight of a mountain range receding into mist might do. He wrote, “Whatever is fitted in any sort to excite the ideas of pain and danger … is a source of the sublime; that is, it is productive of the strongest emotion which the mind is capable of feeling.” This potent conflation of terror and excitement helps account for one of the most obscure and dangerous aspects of the gothic: its villains may commit revolting acts of violence, both sexual and moral, but they are never as repellent as they ought to be. In Maturin’s 1820 novel Melmoth the Wanderer—which inspired my third novel, Melmoth—the titular character, having sold his soul in exchange for a hundred fifty years on earth, displays a pitiless desire to degrade the innocent and torment the wretched, but he does not repulse. The reader may find themselves entertaining not only sympathy for the Devil, but a bit of a furtive crush.

Feeling is at the heart of the gothic, because it is not a genre: it cannot be concocted out of an approved list of motifs. The Hound of the Baskervilles is all moors, candles, curses and monsters, but the presence of Sherlock Holmes—the purest embodiment of reason ever breathed on the page—neutralizes the gothic as effectively as alkaline does acid. How could the Hound be an emissary of hell, if Holmes is filling his pipe? The gothic is, rather, a sensation, like hunger or desire; and, like hunger or desire, you may be hard-pressed to describe it, but you’ll know it when you feel it. Hilary Mantel’s great gothic novel Beyond Black has no crypts or quasi-medieval myth; it is set in the drab and dreary streets of modern suburban England; but from its opening line—“Teatime in Enfield, night falling on Potters Bar”—the reader is conscious of being thrown off-kilter, and of the familiar becoming strange.

The uncanny is a sensation as intrinsic to the gothic as terror and the sublime. In his essay on the uncanny, Freud writes of how it is “that class of the frightening which leads back to what is known of old and long familiar.” Imagine, for example, opening the door of your home to find some many-limbed monster rearing its toothy head: you would scream and run. There is nothing uncanny about that. But imagine, on the other hand, that you open the door and an old friend is waiting for you. At first, they do not turn their head to greet you. Then they do so slowly, with a curious pained movement, and when eye finally meets eye there is a look not of fond recognition but of contempt, and repulsion. Few, I suspect, would choose the latter visitor over the first.

The death of the gothic in literature has been predicted or longed for since the giant’s helmet crushed the luckless heir of Otranto—which, naturally, only adds to its appeal. When Maturin’s Melmoth the Wanderer was published, an outraged critic wrote in Critical Quarterly, “If Melmoth had only been silly and tiresome, we should gladly have treated it with silent contempt; but it unfortunately variegates its stupidity with some characteristics of a more disgusting kind.” The gothic persists, and adapts, too silly to be taken seriously, but too full of sublime terror to leave feathers unruffled. It finds fresh political horrors to satirize and condemn, and new desires to conceal and reveal. It is always available, on the fringe of our society and its fears. In the end, the wan, coal-eyed teen dressed in black who watches gothic horror movies at noon has something of the spirit of the tribes that sacked Rome: barbarous, possibly, but throwing off all that is constraining and polite. By transgressing against all moral and aesthetic norms, we are proposing something more reckless and free.

Sarah Perry is the internationally bestselling author of The Essex Serpent and After Me Comes the Flood. Her most recent book is Melmoth. She lives in England.