CoCo will go go.

Just seven months after inheriting the “Tonight Show,” Conan O’Brien — faced with a timeslot demotion — is close to finalizing his exit from NBC.

O’Brien’s short tenure as host of the storied late night franchise is expected to conclude next Friday. That means Jay Leno will regain the reins of “The Tonight Show,” moving back to the 11:35 p.m. timeslot effective March 1 — the night after the Winter Olympics concludes

O’Brien’s exit from NBC was being finalized Friday, after days of negotiations and plenty of press speculation.

Details of the agreement — expected to be signed over the weekend — were not immediately disclosed. But it’s believed that as part of the settlement, O’Brien will be paid a sum worth more than eight figures — as much as between $30 million and $40 million.

O’Brien is believed to now have the opportunity to launch a new late-night program elsewhere either by fall or early next year. For NBC, agreement allows the Peacock to re-establish Leno at 11:35 for at several months before “The Tonight Show” faces off with former host O’Brien.

The deal was brokered by former agent-turned-Universal COO Ron Meyer, who worked with NBC U’s Jeff Zucker, Jeff Gaspin and Marc Graboff on the Peacock side. O’Brien’s lawyers and reps, including WME’s Ari Emanuel and Rick Rosen, as well as manager Gavin Polone, handled the exit for the host.

Much of the wrangling came down to issues of whether O’Brien’s contract was breached — or whether the host was in breach.

Sources close to O’Brien said they believed the host’s contract made it clear that the “Tonight Show” job was for the 11:35 p.m. time slot. NBC, however, contended that O’Brien’s contract didn’t include time slot specificity — and that they were still keeping him in place on “Tonight,” which was just moving to a new slot.

The outcome reps a financial hit for NBC, estimated by some to be in the hundreds of millions of dollars. Ultimately, it might have been much cheaper to have just stuck with Leno on “The Tonight Show” last year and pay O’Brien’s kill fee (believed to be around $40 million).

Instead, the network not only has to still pay for O’Brien’s exit, but also recently shelled out millions to launch both O’Brien’s “Tonight Show” and the primetime “The Jay Leno Show.”

That includes brand spanking new sets for both shows; moving the O’Brien enterprise from New York to Los Angeles; heavily marketing both series; and then losing ad dollars due to across-the-board ratings declines.

Had the network decided to wind up in this scenario a year ago, Leno would still be in his old digs and O’Brien wouldn’t have gone through the public humiliation of a “Tonight Show” coronation, followed by a demotion seven months later.

O’Brien now becomes a free agent — and most believe that Fox remains the most viable option for the writer/comedian, should he want to jump immediately back in the game. (ABC has already said it’s not interested in adjusting its “Nightline”/ “Jimmy Kimmel Live” lineup, while CBS is accounted for.)

Given the amount of good will O’Brien has garnered among his fan base — not to mention the fact that he has a full staff now suddenly out of work — it’s likely he will want to get a new show on the air as quickly as possible.

Launching a show on Fox, however, is hardly a slam dunk. Well-established late-night hosts like O’Brien come along perhaps once in a decade — so Fox execs may decide that they better act now if they ever want to be in that daypart. (That is, if they ever want to be in that daypart.)

Fox’s owned-and-operated stations, which rep 40% of the country, would likely be able so shuffle their syndication committments around to make way for O’Brien. (Fox owns duopolies in several major markets — including New York, Los Angeles and Chicago — which makes moving those off-net laffers around much easier.)

Beyond that, network insiders predict they could clear an additional 20% — for a total of 60% of the country — in-pattern immediately. But with most affils committed to either off-net syndie fare or newscasts at 11 p.m., it’s unclear when such a yakker might be skedded.

That’s all hypothetical, of course, as no talks have yet taken place between O’Brien’s reps and Fox.

Other options include cable — although at a dramatically reduced budget — or first-run syndication. But O’Brien runs into even tougher clearance problems with syndication that he might at Fox — which is why no distributor has been able to field a successful first-run yakker in the daypart since “Arsenio Hall.”

The quick resolution capped a bizarre nine-day period that began with an erroneous online report that “The Jay Leno Show” was being canceled.

The 10 p.m. strip, which was hurting both the network’s primetime performance and Peacock affiliates’ 11 p.m. news, wasn’t performing to expectations. Under pressure from stations, and facing the likelihood of pre-emptions, NBC Universal TV Entertainment chairman Jeff Gaspin told reporters Sunday that “we realized we had to make a change.”

But rather than find a primetime solution for Leno (or carve out a home for the host on one of its successful cablers, such as USA), the network opted to move Leno back to 11:35, his old “Tonight Show” stomping grounds.

Under a compromised hatched by Gaspin, “The Tonight Show with Conan O’Brien” would move to 12:05 a.m., while “Late Night with Jimmy Fallon” would be shoved to 1:05 a.m.

Gaspin said that scenario repped the best option for the network. But it also meant potentially angering and losing O’Brien — which Peacock brass were apparently ready to do.

Decision came as Peacock execs grew frustrated at O’Brien’s declining “Tonight Show” ratings.

In a high-stakes game of chicken, Gaspin and company decided not to can O’Brien outright — but wait and see whether he’d accept the new setup.

It didn’t appear likely however — and soon after word emerged that O’Brien was upset over the turn of events, the host released a strongly-worded letter on Tuesday, taking the network to task for a plan that would “seriously damage what I consider to be the greatest franchise in the history of broadcasting.”

NBC U’s Dick Ebersol, however, told the New York Times that the late night crisis came about because of “an astounding failure by Conan.”

Ebersol said he had advised O’Brien on making his “Tonight Show” more appealing to middle America viewers, but said O’Brien was “stubborn about not being willing to broaden the appeal of his show.”

Sources close to O’Brien called his statements “preposterous,” and noted that Ebersol’s track record isn’t pristine either (the XFL, for example).

Negotiations to separate O’Brien from “The Tonight Show” and NBC took place all week, while on camera O’Brien tweaked his Peacock bosses — and Leno as well.

“In the press this week, NBC has been calling me every name in the book,” he said on Friday’s “Tonight Show.” “In fact, they think I’m such an idiot they now want me to run the network.”

The controversy, ironically, helped propel O’Brien’s ratings — perhaps giving some Peacock brass pause about cutting him loose so quickly, while helping his chances at landing a home elsewhere.

Thursday’s “Tonight Show,” for example, scored a 1.9 rating among young adults in the metered markets. O’Brien usually posts ratings half that amount.

“NBC is making Conan a bigger star,” one source close to the host said.

Rivals continue to also take aim at Leno and NBC on camera. Jimmy Kimmel was savage in his appearance on “The Jay Leno Show” Thursday night, taking the opportunity to throw jabs to Leno’s face — on Leno’s show.

“Listen Jay, Conan and I have children,” he told the host. “All you have to take care of is cars. We have lives to lead here, you’ve got $800 million. For God’s sake, leave our shows alone.”

David Letterman, meanwhile, has been positively giddy over the situation, enjoying a sense of schadenfreude over the whole affair (given what he went through in 1992).

Another rival, however, took both Leno and O’Brien to task for the creative struggles and ratings drops they encountered in recent months.

“It’s like both of these guys forgot how to make TV,” one source close to a rival show said. He added, however, that he also would have advised O’Brien to walk once NBC downgraded his show to midnight.

“Why be in a place where they don’t want you?”

Besides the uncertainty of whether O’Brien can find a home at Fox — and how that might be done as swiftly as possible — plenty of other burning questions remain.

It’s no guarantee, for starters, that Leno — damaged by his 10 p.m. collapse — will be able to just pick up where he left off at 11:35 and start beating Letterman again.

Who and what O’Brien might be able to bring with him to his next show is also unclear. NBC could decide to enforce intellectual property rights, as it did when Letterman left for CBS. And it’s uncertain whether Richter or Weinberg would make the jump to a new show as well.

There’s also the longterm question of who will now eventually be in line to replace Leno when the host really, truly is ready to retire as “Tonight Show” host. Jimmy Fallon would appear to be the front-runner — but as both Letterman and O’Brien have learned, it’s not easy to move from “Late Night” to “Tonight” without complications.

Leno will likely continue to host his “Tonight Show” from the recently built “Jay Leno Show” stage — just with a few references to his now-gone 10 p.m. timeslot scrubbed from the walls. But what NBC might wind up doing with O’Brien’s soundstage is uncertain.

And how will this debacle impact the tenure of Zucker — who just extended his deal at the Peacock, but is still speculated to exit once Comcast takes over.

If O’Brien can take any solace, it’s that he won’t go down in history as having had the shortest tenure in “Tonight Show” history.

Although the reigns of Steve Allen (2 1/2 years), Jack Paar (just under 5 years), Johnny Carson (nearly 30 years) and Jay Leno (17 years) are cited, “Tonight” also had a few missteps in its early years.

Ernie Kovacs actually served as the permanent Monday and Tuesday host on “Tonight” for four months between Nov. 1956 and Jan. 1957. And after both Kovacs and Allen departed in Jan. 1957, the replacement program — “Tonight! America After Dark,” hosted by Jack Lescoulie and Al “Jazzbo” Collins, ran from just January through July 1957.

Still, given the fact that just a few months ago NBC had put all of its weight behind O’Brien as the future of such a historic franchise, the host is likely dumbstruck by the sudden turn of events.

Prepping for his quick departure, O’Brien has already been running (slightly tongue in cheek) a series of nostalgic “Tonight Show” retrospectives — clips from his seven months on the air.

Now appears as if those “Tonight Show with Conan O’Brien” mugs, magnets and t-shirts are going to soon become very valuable. E-Bay, brace yourself.

Quipped O’Brien on Thursday’s show: “No matter what happens, it’s been a real honor to sit in the same chair as Steve Allen, Jack Paar, Johnny Carson, Jay Leno, and Jay Leno.”