Talk show host Conan O'Brien agreed early Thursday to part ways with NBC, after days of tense negotiations.

The deal clears the way for rival Jay Leno to reclaim "The Tonight Show," broadcast from 11:35 p.m. to 12:35 a.m. Eastern time, beginning March 1. It includes a payout of approximately $32.5 million for Mr. O'Brien and roughly $12 million for his staff, according to a person familiar with the matter.

A statement from NBC Universal and Mr. O'Brien said Mr. O'Brien is free to "pursue other opportunities" after Sept. 1 and that he will make his final appearance as host of "The Tonight Show" on Friday.

Mr. Leno's program will have many of the features familiar to his "Tonight Show" audience, according to an NBC statement. Mr. O'Brien took the reins of "The Tonight Show" last June, after a 17-year run by Mr. Leno. NBC had promised Mr. O'Brien the show five years earlier, as an incentive to sign a new contract with the network.

The NBC statement also noted that "Late Night With Jimmy Fallon" will continue to be broadcast from 12:35 a.m. to 1:35 a.m. Eastern time.

Mr. O'Brien signed the agreement around 1 a.m. Pacific time, people familiar with the matter said.

"We're pleased that Jay is returning to host the franchise that he helmed brilliantly and successfully for many years," Jeff Gaspin, chairman of NBC Universal Television Entertainment, said in a statement. "He is an enormous talent, a consummate professional and one of the hardest-working performers on television."

Tomorrow night is officially Conan O'Brien's last show, as the late night host and NBC reach a deal rumored to cost the network $44 million, Sam Schechner reports.

NBC, which is controlled by General Electric Co., will retain the rights to at least some of the comedic material from the show, according to people familiar with the matter. The deal also includes a nondisparagement clause, both for the 46-year-old Mr. O'Brien and for NBC, according to people familiar with the negotiations.

"In the end, Conan was appreciative of the steps NBC made to take care of his staff and crew, and decided to supplement the severance they were getting out of his own pocket," Gavin Polone, Mr. O'Brien's manager, said. "Now he just wants to get back on the air as quickly as possible."

Mr. O'Brien walks away from "The Tonight Show" after almost eight months on air. His exit comes after NBC hatched a plan to shift Mr. O'Brien's show back by 30 minutes to make way for a half-hour show starring Mr. Leno. Since September, Mr. Leno had been hosting an NBC show weeknights at 10 p.m. Eastern time. That show saw muted ratings.

Mr. O'Brien argued that "The Tonight Show" wouldn't be "The Tonight Show" at 12:05 a.m. and refused to move. He also said pushing the Fallon show back by half an hour would be unfair to Mr. Fallon.

NBC had been under pressure from local television stations that complained that ratings for Mr. Leno's 10 p.m. show were poor and damaging the lead-in to their local news broadcasts at 11. Mr. O'Brien blamed the weak lead-in for his own soft ratings. NBC executives have said Mr. O'Brien shared the blame.

Write to Lauren A.E. Schuker at lauren.schuker@wsj.com and Sam Schechner at sam.schechner@wsj.com