As soon as the shock wore off, the execs and agents knew they needed to move quickly — very quickly.

The 2010 network upfronts were days away, and Fox had just informed Chernin Entertainment and 20th Century Fox TV that it was passing on the pilot that had seemed a slam dunk to land on the schedule, the cops-and-cons action drama “Breakout Kings.”

After Fox’s Peter Rice and Kevin Reilly delivered the verdict on May 12, Peter Chernin immediately began making calls to network and cable buyers. So did 20th’s Gary Newman and Dana Walden, Chernin TV chief Katherine Pope and WME’s Rick Rosen and Ari Greenburg.

The jolt of the pass from Fox, after the pilot had been an early frontrunner and tested superbly, drove the team to do everything possible to give the show a second chance despite the long odds.

Pilot scripts move around all the time, and ongoing series occasionally relocate to new outlets. But it’s extremely rare for a busted pilot to command a series greenlight from another network. Yet within three weeks of the pass from Fox, “Kings” was on its way to a 13-episode order from A&E, where it bows March 6.

The behind-the-scenes story of the move is a tale of an opportunistic gamble by a fast-growing cabler, savvy dealmaking by seasoned TV execs and, most of all, a reflection of the immense faith that the key players had in the ensembler about a wily group of federal marshals who partner with convicted felons to hunt down fugitives.

When “Kings” was suddenly up for grabs, “Our feeling was we should not overthink this,” said A&E prexy-g.m. Bob DeBitetto. “We said, ‘Let’s not be typical TV executives here. The situation is what it is — let’s make the best of it.’ We saw it as a real opportunity to do a show that is different from the kind of shows we’ve been focusing on in our own development.”

Industry insiders say the “not invented here” syndrome frequently prevents worthy projects from getting a second look from other networks. Given the tens of millions of dollars at stake, execs are wary of committing to projects they haven’t nurtured from scratch.

None of this was an issue for Tana Nugent Jamieson, A&E’s senior veep of drama programming, after she watched the screener of the “Kings” pilot she’d received from 20th. She called her boss in New York, DeBitetto, and told him he had to see it as soon as possible. He did and then made the same call to his boss, A&E Television Networks chief Abbe Raven. Soon after, A&E was in exclusive talks with 20th to pick up the show.

“The idea of moving a show is daunting. You don’t really expect to be successful, because most networks prefer their own development,” 20th chairman Newman said. “But we all felt that if there was one (show) that was going to make it, it was this one.”

In deference to its sibling studio and to Peter Chernin’s long history at News Corp., the Fox network was quick to waive its right to hold on to the pilot for another year once talks with A&E got serious.

DeBitetto and Jamieson responded to the show because its law-enforcement procedural theme is a fit with the other original and acquired scripted series on A&E, yet the action elements and younger age range of the ensemble may draw a commensurately younger aud.

As the talks with A&E accelerated in early January, the creators and exec producers of “Kings,” Matt Olmstead and Nick Santora, were steering clear of any chatter about hope for the show. Both had moved on to other jobs — Olmstead joined the staff of the 20th/Chernin drama “Terra Nova,” while Santora signed on to CBS’ “Criminal Minds” spinoff — and were unwilling to get their hopes up again.

Olmstead and Santora had previously worked together closely on Fox’s “Prison Break.” After that show ended in 2009, the two were eager to collaborate again, and because of their track record on “Prison Break,” “Breakout Kings” had strong buzz from the time it was commissioned as a script with a big penalty if not ordered to series, and feature helmer Gavin Hood (“X-Men Origins: Wolverine”) attached to direct.

After riding the momentum for nearly a year, Santora will never forget getting the bad news from his rep, WME’s Greenburg: Fox had unexpectedly decided to stick with bubble shows “Human Target” and “Lie to Me” rather than open up berths for new dramas. Santora and his wife were busy moving into their new home the same day.

“I drove from the studio to my brand new home, got out of the car and, with all the moving boxes and stuff on the front lawn, my wife takes one look at me and says, ‘Oh no.’ I said, ‘Oh yes,’ ” Santora recalled.

“It’s such a weird emotion,” Olmstead observed. “On the one hand, no one died. No one even twisted an ankle, and yet you’re devastated. You have to allow yourself the ability to say ‘I really wanted it’ and then deal with the drop when you don’t get it.”

Santora was in the midst of outlining an episode of “Criminal Minds: Suspect Behavior” when he got the official word that “Kings” was a go at A&E. It was a “surreal” experience to hastily pack up his office on the Disney lot and switch his writer’s brain back to the tone of “Kings.”

“It’s as if your dog died, you drive it to the crematorium and when you take it out of the back seat, it starts barking at you,” Santora said.

In Pope’s view, the stars aligned for “Kings” due to the sheer will of those involved with the project. “Kings” was among the first pilots fielded by Chernin Entertainment, so it was naturally a high priority for them and for the studio.

“This wouldn’t have happened without the strong backing of Dana and Gary in a way that was definitely above and beyond,” Pope said. “They had to take the leap of faith on figuring out the budget and the (talent) deals. You never want to get into situation where you’ve sold something but you can’t produce it.”

The ability to get it all done was greatly enhanced by the willingness of all parties to stick with the show, which is a blend of high-octane action with occasional doses of humor — with an emphasis on repartee among key characters that resembles the fast wit and finish-each-other’s-sentences vibe between Olmstead and Santora. In a sign of how good the pilot experience had been for the actors, the key cast members — Laz Alonso, Domenick Lombardozzi, Brooke Nevin, Malcolm Goodwin and Jimmi Simpson — were willing to downsize their salaries to make the show work on a cable budget.

It also helped that “Kings” was never designed as a big-budget network show. The plan had already been to shoot in Toronto, where the pilot was lensed. The production formally shifted from 20th Century Fox TV to its Fox 21 unit, which is set up for cable and lower-budget fare. It’s understood that the baseline episodic budget for “Kings” was trimmed to about $2.2 million-$2.4 million from about $2.8 million had it gone to Fox.

“We had to do a little bit of work to make for a reasonable budget for A&E — but not a lot of work,” DeBitetto said. “It was not that big of a divide.”

Among the concessions beyond salaries across the board was shifting to a seven-day shooting sked rather than the standard eight for most network primetime skeins. Olmstead and Santora credit producer Ed Milkovich for working budgetary magic to stretch their dollars across the 12 additional episodes — even in the face of uncooperative weather conditions in a particularly snowy Toronto winter. Lensing on “Kings” wrapped earlier this month.

For A&E, an additional wrinkle was that the deal came together just as its ad sales execs were sitting down with media buyers to negotiate upfront sales for the coming season. All of a sudden, the sales force had a new property to factor in to its sales pitches and ratings projections.

In a twist of programming fate, “Kings” wound up benefiting from the drama at A&E sibling cabler History over the eight-part “The Kennedys” miniseries that was yanked at the 11th hour last month. “Kings” was able to absorb some of the marketing that had already been purchased or earmarked for the History mini.

When the cast and crew reunited last fall, the atmosphere on the set was close to jubilation. Adding to the celebratory mood was the fact that Hood, the director of the pilot, journeyed back up north to direct the second episode.

“He didn’t have to, by any means,” Olmstead said. “It was his gesture of appreciation.”

Also significant to Olmstead and Santora has been the trust demonstrated by A&E execs.

There were no changes made to the pilot, and execs were nothing but supportive as they tackled the episodic production. The first time the showrunners even spoke with DeBitetto and Jamieson was at a dinner at the Four Seasons in Beverly Hills to celebrate the finalizing of the series order.

Olmstead is impressed by the risks A&E execs took on giving “Kings” a go.

“I respect the balls that they have to pick up a pilot developed by somebody else,” Olmstead said. “To do that you have to be very objective and a bit of a gambler. … We’ve always remembered the fact that this thing was toast, and to come out of the ashes like we did just makes it that much sweeter. We’ve never lost sight of the fact that A&E really, really stepped up for us.”