In 1801 the British have risen to power in Egypt and suppress the worship of the old Egyptian gods. A cabal of magicians plan to drive the British out of Egypt by bringing the gods forward in time from an age when they were still powerful and unleashing them on London, thereby destroying the British Empire. In 1802, a failed attempt by the magicians to summon Anubis opens magical gates in a predictable pattern across time and space.
In 1983, ailing millionaire J. Cochran Darrow has discovered the gates and found that they make time travel possible. Darrow organizes a trip to the past for fellow millionaires to attend a lecture by Samuel Taylor Coleridge in 1810. He hires Professor Brendan Doyle to attend and give expert commentary. One of the magicians, Doctor Romany, happens to spy the time travelers and kidnaps Doyle before he can return. Doyle manages to escape torture and flees back to London, now trapped in the 19th century.
Doyle joins a beggars guild and meets a beggar named Jacky. He plans to meet and befriend William Ashbless, a wealthy poet that Doyle has studied profusely, in order to gain a benefactor. Doctor Romany scours the city for Doyle with his legion of murderous beggars, led by the clown-magician Horrabin. At the same time, Doyle discovers that Darrow has remained in the 19th century to search for Dog-Face Joe, a body-swapping werewolf, in hopes of bribing Joe into granting him a healthy new body. Doyle himself becomes targeted by Joe, receiving the poisoned body of Darrow's former bodyguard, but manages to cure himself of the poison.
In his new body, Doyle realizes that he himself is the historical Ashbless. He copies down Ashbless' poetry from memory and deduces his own future from his study of Ashbless' life. Using this knowledge, he continues to thwart the magicians' plans. After Romany discovers a gate to 1684, Doyle follows him through and stops his attempt to change the past. Meanwhile, Darrow successfully contacts Dog-Face Joe and organizes a deal in which Joe will provide Darrow with healthy bodies and allow him to live forever.
Doyle eventually returns to 1810, but is kidnapped and brought to Muhammad Ali's Egypt, where the magicians' Master tempts him with resurrecting his dead wife if he will tell them the secrets of the time-gates. Doyle resists and kills the Master. Meanwhile, Jacky discovers Darrow's secret and kills him along with Dog-Face Joe. Doyle returns to London, where the last magician, Romanelli, kidnaps him, Jacky, and Coleridge. In a drugged stupor, Coleridge frees Horrabin's twisted menagerie of monsters, allowing him and Jacky to escape. Romanelli escapes with Doyle to the underworld, but is eaten by Apep while Doyle is rejuvenated on board the sunboat of the god Ra. Doyle meets back up with Jacky and discovers that not only is Jacky secretly a woman, she is his future wife.
Decades later, after living out Ashbless' entire life and becoming a widower, Doyle goes out to meet his historic date with death. Doyle discovers that his intended murderer is a duplicate of himself that the Master had made in Egypt decades before. Doyle kills the duplicate, thereby supplying the corpse for his death, and boats away into an unknown future.