NightOfI had been hearing about the mysterious HBO pilot for years. A friend who had seen the work, shot in 2012, described one of the most fascinating crime tales he’d ever seen, describing in detail the set up for the case in which a taxi driver gets mixed up in a brutal murder.

The one snag: It starred James Gandolfini in what would have certainly been the only kind of role to approach his signature work for that same network, as Tony Soprano. And after shooting just that one remarkable pilot, he died unexpectedly in Italy in June 2013, leaving the whole project in limbo.

Was it possible to go on with it without him, even though he was listed as executive producer? Years went by, and it was clear following the critical decline of “True Detective” and cancellation of “Vinyl,” that HBO needed a solid hit. My friend kept repeating the plot summary every summer when I’d see him.

And now, with a title change (to something bland and terrible) and a dour set of promos (that make it look avoidable) the series is here, seemingly buried in the midsummer, as last summer’s great miniseries “Show Me A Hero” seemed to be.

Still, “The Night Of” (HBO, 9 p.m.), as it is now called, is every bit as compelling as my friend told it, especially tonight’s gripping setup.

It stars Riz Ahmed as a Pakistani-American college kid in Queens who borrows his dad’s taxi to go to a party in Manhattan. He never gets to the party; people keep getting in the taxi thinking he’s on duty (he can’t figure out how to turn the Off Duty sign on). It’s an annoyance until a distraught young woman (Sofia Black-D’Elia) climbs in dreamily and wants just to go to the beach. The kid, Nazir Khan, known as Naz, is game, and they get to know each other on the banks of the inky East River.

One thing leads to another, they go to her place, and though she’s a little scary and dangerous, he stays over. When he wakes up, she’s dead from a vicious stabbing. He doesn’t quite know what to; he certainly doesn’t have the ability to fully escape, so he’s collared.

That’s when the rest of the series revs up; where amid the dinginess and dead ends of the police precinct, amid the ancient vinyl flooring and cages, where even the vending machines don’t work, there are still flinty minds both in the detective’s bureau, where a detective named Box (Bill Camp) takes up the case, and in the legal system, where a down and out attorney who catches wind of the sad kid, takes up the case.

That was where Gandolfini’s role was, as the precinct ambulance chaser John Stone; and here it’s done masterfully by John Turturro, as a guy stricken with his own unappetizing foot malady, eczema, that everybody seems to know about. He’s a walking metaphor for the broken system where he works and the rest of “The Night Of” will unfold, with a little less of the sheer tension, but just as much intrigue.

Based on a British series, “Criminal Justice” that aired in 2008-9, Its gritty detail is due in part to the script from Steven Zairian (“Schindler’s List”) and especially Richard Price, the novelist who added such authentic touches to “The Wire” (whose Michael K. Williams also has an eventual role in the new series). After so many years of “Law & Order” and other cop shows, you’d think we’d have a keen understanding of what goes on in New York police investigations, but this all seems to bring it to a new level.

At a time when police work, race and the assimilation of Muslims in America are all urgent topics, there is an immediacy to “The Night Of” that belies the amount of time it spent in limbo.

It is the series you must watch this summer.