In the spring of 2013, I got a call at my desk at The New York Times from Ari Emanuel, one of Hollywood's top power players as the co-CEO of the William Morris Endeavor agency.

I had known Ari for years, and worked on a number of stories involving his clients. That day he had called to pose a provocative question: "Do you want to get in trouble together with me?"

Well, why not? I listened as Ari laid out a plan he was working on: Had I heard about the drama "Criminal Justice," which HBO had just passed on -- even though it was to star James Gandolfini? I told him I had read accounts in the Hollywood trades of the decision to pass on the project.

"Well here's what I have for you," Ari said. "I'm going to sell it to Netflix."

This merited a "Whoa!" The idea that a project passed on by HBO might end up on Netflix, already beating its breast to pronounce itself as HBO's uber rival for premium television content, was intriguing enough. That the project was to be headlined by the signature star of HBO, Tony Soprano himself, made it a story oozing juice.

We agreed I would write as soon as a deal was completed. Ari said it would take some days, and in the meantime he would send me the pilot, which I could watch or not. The story didn't really depend on it. The disk arrived the next day.

I had some free time that night, and without any expectations, I slid the disk in and sat down to watch.

What I saw left me limp. It was as tense and riveting a pilot episode as I could ever remember seeing, surely one of the five best I had seen in my career covering television. And HBO had passed on it? With James Gandolfini in it?

Now I had two reasons for wanting Ari to finish his deal to place the show elsewhere: a great story to write AND a chance to see a next episode.

It has taken three years for me to see that next episode. (Also great.) The series no longer stars Gandolfini, of course; he died suddenly, only a couple of months after that first call I got from Ari. The show got a new lead, John Turturro, and a new title, "The Night Of." But it didn't get a new network: it premieres Sunday night on HBO.

What transpired during the long road from the inception of the project to its introduction to the public is one of those tales of convoluted television machinations that seem to mark the backstory of so many standout shows.

In this case, the project began in 2009 when HBO made a deal to buy the format of a BBC series called "Criminal Justice." The network had for some time been hoping to work with the celebrated screenwriter Steve Zaillian ("Schindler's List," "Moneyball"), and this project looked ideal for him. Zaillian's film career was going well and he was not looking to work in television, but he eventually signed on, mainly after he and his producing partner, Garrett Basch, decided to bring in the novelist and screenwriter Richard Price, who had also worked on "The Wire," as the principal writer.

Gandolfini had worked with Zaillian on the movies "All the Kings Men" and "A Civil Action," so it made sense to slip him the script. He was in. The pieces were in place. The pilot, directed by Zaillian, was shot on location in New York late in 2012.

The production team was elated with the result: an excruciatingly tense, minutely detailed exploration of a murder case, with a luckless chief suspect, an enigmatic victim, a stew of drugs and sex, a cunning lead detective, and a shambling, ambulance-chasing defense lawyer -- Gandolfini, who had no more than two minutes of air time in the pilot.

Then HBO saw it -- and passed. No definitive reason was ever given to the production team. HBO had wanted certain changes, but Zaillian was committed to his vision, and executed it precisely in the pilot. When they got the word, the production team was baffled -- and a bit crazed. No one more so than Basch.

Basch decided to go rogue, quietly setting up a screening of the pilot for Ted Sarandos, the chief content officer for Netflix, and two other Netflix executives, Cindy Holland and Nina Wolarsky. The group made no effort to contain their enthusiasm, sending the show's ownership team a clear message: we love this series and we will do whatever it takes to get it.

Ari Emanuel's call to me followed after that conversation. There was a complication, however. HBO had a protective clause in its deals allowing the network to block any show it commissioned from going to another premium program service, such as Showtime—or Netflix.

While Netflix was trying to work around that impediment, some other prospects popped up. One was ABC; the other, more promisingly, was FX.

In his quest to keep the project alive somewhere, Basch had also contacted John Landgraf, the highly respected president of FX. Landgraf was willing to take a look at the pilot -- and, like almost everyone else, he was blown away by its quality.

FX had previously cooked up the appropriate format for this kind of show: a "limited series." That involved a single story told in a finite number of episodes, between eight and 13 -- a show that might be brought back in succeeding seasons with new plots and characters. "American Horror Story," the model, had already worked on FX starting in 2011. Landgraf called with an excellent offer to bring "Criminal Justice" to FX.

The FX offer was the breaking point for HBO. As a basic cable channel, FX was not subject to the prohibition against HBO projects moving to premium networks. HBO needed a solution. It found one in the concept of a limited series. Michael Lombardo, then heading entertainment for HBO, called Kary Antholis, who was in charge of mini-series, and asked if he would watch the pilot.

Antholis, like most everyone else, found the pilot completely compelling. He advocated for picking it up as a limited series. The crucial difference between that definition and a standard series was in the expectation of a second season.

Antholis suggested that HBO had been reluctant initially to order "Criminal Justice" as a traditional series mainly because of what he called "the pressure." Ordering a true series, he said, implies the expectation of a second season. A series could never be considered a success without a second season, while a "limited series" certainly could.

"In the British version, the second season was nowhere near as good as the first," Antholis noted, citing another reason for HBO's initial reluctance.

Going with the limited series concept seemed to satisfy everyone's needs. Steve Zaillian had not been not entirely convinced he wanted to make a continuing series. He conceived of the project as an eight-part movie.

Pre-empting both Netflix and FX, HBO re-entered the picture with its limited series offer. Soon after, the deal was accepted. Antholis met for dinner in Los Angeles with Zaillian, Richard Price and Gandolfini to celebrate the consummation of the deal.

A few weeks later Gandolfini was dead, and the project again derailed—only temporarily. HBO, looking for a new star to play the lead, signed Robert DeNiro. But other commitments quickly made his participation impossible. A short time later John Turturro, who had been an original contender for the lead, signed on.

Still, the process moved slowly. "Steve is extremely meticulous," Antholis said. Zaillian wanted all the scripts written before production began. He also wound up directing every episode. "Ultimately, Steve is like a painter," Antholis said. "He controls every aspect of the process."

Now HBO, which is increasingly hungry for a new drama hit, is as impressed with the result as so many others were along the way. No commitment to a sequel has been made, though Antholis acknowledged discussions have taken place. "If it's a success, as we hope it will be, we will certainly explore it," he said.