When Alex, the central character in The Spell, takes ecstasy, the narrative takes it with him. In a shallow sleep we follow his "racing dreams of ceaselessly mutating forms, bright and artificial as toy jewellery", we listen with him to the calls and voices that he cannot get out of his head.

There ought to be a special rhetorical term for this: narcopoeia, or some such. For the imitation by writers of the effects of drugs has a long literary tradition. Even before De Quincey recorded "the fierce chemistry of my dreams" in Confessions of an English Opium Eater, or Coleridge appeared to make "Kubla Khan" out of a laudanum trance, the eminently respectable 18th-century poet Thomas Warton was turning opium to verse in "The Pleasures of Melancholy".

Writing that tries to replicate the effects of drugs is much rarer in novels before the late 20th century, though many have guessed that passages from writers such as Edgar Allan Poe and Wilkie Collins "must" have been drug-influenced. In Jack Kerouac's On the Road (1957), however, it becomes explicit. The novel was written rapidly on large quantities of Benzedrine and reproduces the effects of amphetamines. Sentences that talk of "the rhythm and the IT of our final excited joy in talking and living to the blank tranced end of all innumerable riotous angelic particulars that had been lurking in our souls all our lives" are clearly pretty "tranced" themselves.

The newest literary drug is ecstasy, its effects already traced in Irving Welsh's 1996 novel of the same name. Alan Hollinghurst knows that the drugged seem boring or idiotic to the undrugged, and in the first drug experience narrated in The Spell makes the banality of what is thought part of the narration.

Civil servant Alex takes ecstasy for the first time at a club and the narrative, told from his point of view, takes us from scepticism to wide-eyed amazement at nothing much. Speaking with "an exaggerated desire not to exaggerate", he monitors the lack of effect of the chemical in a way that is already chemically slanted. And then perception tilts into rapture. No longer is he an awkward 1980s disco dancer. "He danced like everyone else now, but better, more remarkably." The last adjective preserves his absurd headiness. "It seemed that happening and happiness were the same, he must remember that, to tell everyone." But no such thought can outlast the spell of the moment.

The novel tries to distinguish the effects of different drugs. Ecstasy prose is entranced, but when Danny snorts cocaine it is an "amusing surge of energy", a self-pleased sense of power: "he was olympian, but alight." These are Danny's ridiculous words for himself. When Robin smokes cannabis with Lars, conversation becomes comically bogged down and we see things in a way that is both observant ("Lars's movements were decisive but inaccurate") and befuddled ("the simple fact of enunciation was preposterous").

In characters' sober moments, they sometimes recall the spell of drugs. The hypnotic resonance of nearby church bells, "the dense sonic aura", sounds to Danny "like some acoustic perception you might have in the trance of an E". In an Italian restaurant, eating tagliatelle opposite a poster of Sicily, Alex senses "the oneness that he had felt on ecstasy, which came back now and then like an image from a dream that surfaces again in absent-minded mid-morning".

A novelist, unlike a film-maker or journalist, does not have to include a cautionary word or two. When a character arrives who disapproves of drugs he is a gay, religious oddball called Gordon. "I prefer the high of life," he declares. "'Ah, that,' said Robin." The dry dismissal of the cliché is lost, of course, on his interlocutor. The spell of drugs in this novel is as ecstatic as the spell of sex. It is too good to be true. On ecstasy a second time, Alex recalls the first time, hand-in-hand with Danny on the London streets at 5am, "in the magically protracted hour when he knew that his life had been given back to him". But this is the last line of a chapter, and the next time we encounter the two of them Danny is calmly calculating how to dump Alex. Trances evaporate.

· John Mullan is senior lecturer in English at University College London