THE ARABIAN NIGHTMARE By Robert Irwin Viking. 282 pp. $16.95

Several British publishers, perhaps misled by comically involved synopses, had refused "The Arabian Nightmare" before Robert Irwin, with some colleagues, founded a small firm called Dedalus to launch the book in 1983. Irwin soon found he had a cult classic on his hands. Taking notice, Viking soon picked up his second novel, "The Limits of Vision" (1986), releasing it both in Britain and in America, where it has received some acclaim, and now finally presents "The Arabian Nightmare," slightly revised, handsomely designed and evocatively illustrated, to readers here.

Deft and lovely, and much harder to describe than to experience, just as dreams are, "The Arabian Nightmare" (which of course derives from "The Arabian Nights") is a tale about dreams told as a dream. Fables within dreams within stories within nightmares tumble after one another, but nothing that matters is ever unclear, or contorted or laborious. Synopsis, as some publishers must have found to their current regret, fatally distorts the smooth, steely Ancient Mariner grip of Irwin's real storytelling genius, for like a vision half-remembered but hauntingly vivid, "The Arabian Nightmare" suffers considerably when exposed to daylight.

It is almost the end of the 15th century. The reverberations of the fall of Constantinople still echo round the Mediterranean. Young Balian of Norwich, ostensibly a pilgrim on his way to view the relics of St. Catherine in the Sinai desert, but also a secret spy for the French court, arrives in Cairo on June 18, 1486. As soon as he enters the caravanserai within the great jammed polyglot city, he falls asleep. He soon awakens, or dreams that he has awakened. He dreams again. He awakens. Soon he cannot tell what state he is in, nor does it matter.

What matters is "The Arabian Nightmare," a condition no one can be conscious of while awake, but which in dreams subjects one to an infinity of suffering. The nightmare is possibly contagious. It may also identify anyone who suffers it as the new messiah. Asleep or awake, Balian, who may be a victim, finds himself drifting ever deeper into the stifling complexities of a Cairo choked with magicians, courtesans, thieves, beggars and bards, all themselves thrown into turmoil by the nightmare, and by the disorienting dream city it has seemingly brought to the surface from the nether world. Desperate to control his dreams, which he fears may be eternal, Balian falls into the clutches of the Father of Cats, a magician whose mortal foe is none other than the leper Jean Cornu, grand master of the Poor Knights of Lazarus.

Here the plot begins to thicken. As in a dream of pursuit, the deeper Balian burrows into the underlife of Cairo in his attempt to escape the enemies he cannot identify, the nearer he approaches the nightmare adversary who ultimately tells the tale. For much of the novel, the storyteller Yoll seems to be the responsible party, but on his strangulation it becomes clear that he is yet another mouthpiece of the final dreamer of "The Arabian Nightmare." Irwin is too cagey to identify this figure in any clear way, but the last teller of stories in the novel, he who awakens Balian into a final dream, is an ape.

As benefits an Arabian tale, djinn have figured throughout "The Arabian Nightmare," variously disguised; but no matter what face he may happen to bear, each djinn is ultimately a manifestation of Shaitain, or the Ape of God. The final teller of "The Arabian Nightmare" is that ape. The nightmare -- the feverishly mortal world that Cairo stands for -- is a dream of the Devil's. It is contagious. Balian awakens in Hell.

This may not be exactly a message of good hope, but the book that embodies it with such unstoppable exuberance is anything but gloomy. The tales Balian lives -- and the one he's told -- are in turns hilarious and hallucinatory. The figures he meets in the ape's dream of this world are intensely vivid, exorbitant but real. "The Arabian Nightmare" is a joy to read.

As a teacher of medieval history who has published in the field, Irwin clearly knows Mameluke Egypt very thoroughly indeed and has anchored his most fantastical flights with details that seem clearly authentic. His rendering of many-gated Cairo may owe something to Franz Kafka and Luis Bunåuel, because it is impossible -- for Balian or anyone else -- to escape from the metaphysical coils of the city, but another city comes to mind as well, and another writer with a hallucinatory eye and encyclopedic command of actuality. The city is London, and the writer is Charles Dickens. If Dickens had lived to complete "The Mystery of Edwin Drood," the full tale when told might have had something in common with the visionary urban dreamscape Robert Irwin has so joyfully unfolded in this book.

The reviewer is the book review editor of the science fiction quarterly Foundation