The tens of thousands of fans who crowded into SoFi Stadium in Los Angeles for WrestleMania this weekend got to watch wrestling icon John Cena be hurled to the canvas by Austin Theory, one of World Wrestling Entertainment’s biggest stars.

But offstage, bankers and executives huddled in conference suites at the stadium to put the finishing touches on a new plot for W.W.E.’s future. Endeavor, an entertainment colossus run by Hollywood power broker Ari Emanuel, was finalizing a deal to acquire W.W.E. and merge it with Ultimate Fighting Championship, the combat sports league Endeavor owns.

News of the deal, which aims to create a new public company worth more than $21 billion, broke Sunday before the second night of WrestleMania, with Mr. Emanuel in attendance alongside Vince McMahon, the executive chairman of W.W.E. The companies announced the deal Monday morning, saying the as-yet unnamed firm — whose stock will trade under the symbol “TKO” — would be a juggernaut in live entertainment and combat sports. The deal is expected to close near the end of the year, pending regulatory approval.

“Must-watch TV is a rarity these days,” said Mark Shapiro, Endeavor’s president and chief operating officer, who will also have those roles at the new company. “And unicorns like the U.F.C. and W.W.E. will be heavily in demand.”

In fusing Ultimate Fighting Championship with World Wrestling Entertainment, Mr. Emanuel and Mr. McMahon are betting that traditional TV companies and video-streaming giants will continue to pay top dollar for the rights to show live events — including scripted and unscripted fights.

Recent deals for live sports bear that out. The National Football League in December struck an agreement with YouTube TV that values its Sunday Ticket package of games at as much as $2.5 billion annually — an increase of about $1 billion from the deal with its previous partner, DirecTV. The National Basketball Association is expecting to sharply increase its fees after its current TV agreements expire following the 2024-25 season.

The intense competition between cable TV and deep-pocketed tech companies is behind the ballooning costs. As viewers abandon traditional television in droves, live events like N.F.L. games and W.W.E. matches continue to draw big ratings, helping anchor the cable TV business. And tech giants like Amazon and Alphabet are using live sports to draw new subscribers to their services, creating a bidding war with their traditional rivals.

Executives aim to use the tie-up of W.W.E. and U.F.C. to take advantage of that demand. U.F.C.’s contract with the Walt Disney Company’s ESPN division ends in the next few years, and W.W.E.’s deal with NBCUniversal’s U.S.A. network and the Fox broadcast network are set to expire next year.

The combination is the latest in a series of audacious deals struck by Mr. Emanuel, the workaholic Hollywood talent agent who rose from the mailroom to become one of the entertainment industry’s most important figures. Mr. Emanuel will be the chief executive of the new company and will keep his C.E.O. title at Endeavor, which will continue to own other businesses, including the William Morris Endeavor talent agency and the Professional Bull Riding league.

The deal also provides a coda to a tumultuous chapter in Mr. McMahon’s career. He was reinstated as executive chairman of W.W.E. in January after resigning from that position last year following an investigation into allegations of sexual harassment. Mr. McMahon will stay on at the new company as executive chairman, part of an 11-person board that will include six members from Endeavor and five members from W.W.E.

Dana White, the president of U.F.C., will keep that role, and Nick Khan, the chief executive of W.W.E., will stay on as president. Patrick Whitesell, the prominent Hollywood executive and agent who represents actors including Matt Damon and Ben Affleck, will remain executive chairman of Endeavor.

The deal puts a hefty valuation on U.F.C., which Endeavor and its backers purchased for about $4 billion in 2016, and W.W.E., which was seeking about $9 billion in a deal. The all-stock deal values U.F.C. at $12.1 billion and W.W.E. at $9.3 billion. Mr. Shapiro said that the competitive bidding process justified the “healthy price” for W.W.E., along with the potential for a lucrative deal in its upcoming rights negotiation.

Endeavor is also betting the price tag will be justified by businesses other than rights. Mr. Shapiro said that the company’s capacity to sell sponsorships, create new events and strike deals with social-media companies contributes to its value.

The deal for W.W.E. came together quickly. Over the past several weeks, Mr. Emanuel and Mr. Shapiro visited W.W.E.’s headquarters in Stamford, Conn., and the offices of the investment bank The Raine Group in New York City to finalize the details of the agreement. On Sunday, as WrestleMania reached its conclusion, Endeavor and W.W.E. pinned down the final details.

“It’s been crazy,” said Mr. Shapiro, the Endeavor executive.