Finishing David Taylor’s “Night Work,” I immediately regretted not having read its predecessor first. Titled “Night Life,” it came out last year and introduced Detective Michael Cassidy, a hard-boiled New York cop.

Wading into a whodunit series – in this case, it’s actually a who’ll-do-it – midway means missing out on the pleasures of prior suspense. Secrets that would have been fun to puzzle out in the first book become just so much backstory in the second.

Still, “Night Work” is the best piece of crime fiction I’ve read in years, so good that I will start again with “Night Life.”

This is a genre laden with booby traps, not just for the detective, but for the writer as well. Entering a world dominated by Dashiel Hammett and Raymond Chandler is not easy without producing either a slavish imitation or a send-up pastiche.

“Night Work” gets it exactly right. Taylor, who grew up in New York, worked in the TV and film industry and now splits his time between Boston and midcoast Maine, lets the reader revel in the uncertain mood of 1950s New York, with its fedoras and flashy ties, while taking us deep into the frenetic criminality of pre-revolutionary Cuba. It’s all recognizably noir, but fresh and stylishly written.

It helps that nothing here is quite as it seems, beginning with our hero. Like Chandler’s Philip Marlowe and Hammett’s Sam Spade, Michael Cassidy is a tough loner with few illusions, but he has dreams that sometimes foretell the future. He is not Irish (as one might expect a New York cop called Cassidy to be). His father, Tom Cassidy, changed his name from Kasnavietski when he arrived in America as a fugitive from the czar’s army.

Tom married a millionairess and became a successful Broadway producer. (Taylor’s father was a famous Broadway playwright.) Michael is a product of New York’s Upper East Side, even if he has little time to enjoy it. As a hardened cop says, with grudging admiration, “You’re out there knocking yourself out on the street keeping the animals in line.”

The plot is set against Fidel Castro’s first visit to New York. Fidel has just delivered Cuba from the dictator Batista, but he has not yet become a full-fledged communist and American bete noire. Still, someone is out to assassinate him. Can Cassidy stop it? Taylor’s twists and turns amply compensate for the fact that we know he can.

Taylor is a diligent researcher. Story-spinning and the event itself dovetail seamlessly, even though there’s a bit of authorial license with dramatic possibilities that never made the news. Nor does he hesitate to incorporate actual figures in the story’s action: besides Castro, FBI Director J. Edgar Hoover and (slightly strangely) mobster Frank Costello, among others, have more than walk-on roles.

Though the author would have been only 15 in 1959, the year in which “Night Work” takes place, he exhibits the native New Yorker’s inherent empathy for the sounds and especially sights of his city over half a century ago. Little tidbits, such as the year 6th Avenue was made one-way (1957), are thrown in quite naturally, an event about which anyone living on Manhattan at the time would have had strong opinions.

With some of the minor characters, Taylor can’t resist a little “pulp fiction” fun. Of a trio of hoods, the one with the rifle “preferred to work up closer, because he liked to see the impact”; his brother “discovered an affection for explosives and could shape a charge in such a way that the target would lose his foot, his hand, or his entire being when he turned the key to his car.” The third was “a more straightforward goon who liked to work in close with a knife.”

The tone of the book reminded me a little of Alan Furst, whose works explore a similarly murky world, that of Europe teetering on the brink of World War II.

Cuba and New York are racier settings. Imbued with the smoke of Camels, Chesterfields and Luckies, and haunted by the strains of jazz, David Taylor’s novel recreates a similar, increasingly distant time that’s well worth such an exciting visit.

Thomas Urquhart is a former director of Maine Audubon and the author of “For the Beauty of the Earth.”