Heisting has always been a habit of Doctorow’s, from his first novel, ““Welcome to Hard Times,’’ where he borrowed from movie Westerns, to ““Bil-ly Bathgate,’’ which reworked the legend of gangster Dutch Schultz. In none of these books has Doctorow tried to hide his tracks. Rather, he’s taken history and its legends and used them like armatures around which he’s wound new plots and themes. ““The Waterworks’’ uses the hackneyed story of a mad scientist as an excuse to reinvent the New York City of 1871 and to explore the polar pull of ethics and experiment. When old Augustus Pemberton dies, he leaves his wife penniless and the world wondering where his fortune went. After his son Martin, an acerbic freelance literary critic, claims to have seen his father alive and then disappears himself, a newspaper editor named McIlvaine starts investigating. The secret he helps uncover involves helpless orphans, addled old rich men, a secret laboratory and the search for eternal life.

With that plot summary in hand, any late-show channel surfer could foretell the ending of ““The Waterworks.’’ But that hardly matters, because in stories like this, atmosphere is everything, and Doctorow is a master of atmosphere. New York in the late 1800s has lately inspired novelist Caleb Carr in ““The Alienist’’ and movie director Martin Scorsese in ““The Age of Innocence.’’ But Doctorow’s is the best version yet. In his artful hands, Manhattan becomes the book’s most memorable character, its flawed hero. The gutter vitality of the grimy old city seeps through every page, malign but also magical: ““A mansion would appear in a field. The next day it stood on a city street with horse and carriage riding by.’’ It was ““as if, with a mind of its own, the city was building itself.''

Doctorow is not a first-rate thinker. What he has to say about the evils of power and unchecked ambition has been better said elsewhere. But he knows the art of storytelling inside and out, and in ““The Waterworks’’ he weaves a spell of genuine creepiness. Reading this novel, one is reminded of that wonderful exchange in the 1934 Universal movie ““The Black Cat,’’ where the feckless hero exclaims, ““Let’s cut out this metaphysical baloney.’’ To which Bela Lugosi murmurs, ““Metaphysical, perhaps. Baloney, perhaps not.''