Ending his brief reign as host of one of television's longest-running shows, Conan O'Brien today finalized a rich severance deal with NBC that releases the comedian from "The Tonight Show" and frees him to join another network in time for the new fall season, an NBC spokeswoman confirmed.

The settlement, hammered out over the last week, brings to an abrupt end O'Brien's nearly 20-year career with NBC, where he began as a staff writer for "Saturday Night Live" in the late 1980s. His separation from NBC includes a payout that will go down as one of the most eye-popping in the annals of Hollywood: O'Brien, who has 2 1/2 years remaining on his contract, will walk away with about $32 million, according to people close to the negotiations who spoke on condition of anonymity because they were not authorized to discuss the matter publicly.

Overall, NBC will have to shell out $40 million to $50 million to close the book on its late-night drama.

NBC agreed to compensate the show's staff members, including executive producer Jeff Ross. About 190 people worked on the show, including nearly 70 people who relocated to Los Angeles from New York early last year to work with O'Brien at the program's newly built studios on the Universal lot. NBC and O'Brien's team spent the last few days ironing out severance packages for all the show's workers.

O'Brien's manager, Gavin Polone, said the talk show host would kick in some of his own money for his staff as well.

O'Brien's final "Tonight Show" appearance will be Friday. But he may not be off the air for long. The comedian will be allowed to work on a competing network by September. Jay Leno will be back in his old time slot even sooner. Leno, who surrendered "The Tonight Show" to O'Brien last spring and then was handed his own prime-time show on the network at 10 p.m., will return to late night after NBC's Olympic coverage concludes at the end of February.

The costly resolution ends two weeks of high drama that damaged the images and reputations not only of NBC executives, but also of Leno, who was painted as the villain by many in the media including CBS' David Letterman, who took numerous jabs at Leno over the last week. He was also the target of a grass-roots Internet campaign to demonstrate support for the embattled O'Brien. Earlier this week, Leno provided his side of the story on his program, saying he told NBC executives that he was skeptical that a prime-time show would work.

It was an undignified end to O'Brien's long career at NBC -- he spent 16 years as host of "Late Night With Conan O'Brien" -- and his short tenure at "The Tonight Show." Certainly this was not how NBC anticipated O'Brien's run with "The Tonight Show" playing out when it declared him the "king of late night" in June after he made his debut as host.