AT&T Inc. agreed to spin off its media operations in a deal with Discovery Inc. that will create a new entertainment company, merging assets ranging from CNN and HBO to HGTV and the Food Network.

The AT&T Inc. logo is displayed outside a store in New York

AT&T will receive $43 billion in cash, debt securities and debt retention, with AT&T shareholders getting stock representing 71% of the new company, the companies said in a statement. Discovery Chief Executive Officer David Zaslav is to lead the new entity.

The plan, first reported by Bloomberg News, would combine Discovery’s reality-TV empire with AT&T’s vast media holdings, creating a formidable competitor to Netflix Inc. and Walt Disney Co. It marks a retreat for AT&T’s entertainment-industry ambitions after years of working to assemble telecom and media assets under one roof. AT&T gained some of the biggest brands in entertainment through its $85 billion acquisition of Time Warner Inc., completed in 2018.

The transaction includes all of AT&T’s WarnerMedia operations. In addition to CNN and HBO, AT&T’s WarnerMedia division owns Cartoon Network, TBS, TNT and the Warner Bros. studio. Discovery, backed by cable mogul John Malone, controls networks such as TLC and Animal Planet.

“This agreement unites two entertainment leaders with complementary content strengths and positions the new company to be one of the leading global direct-to-consumer streaming platforms,” AT&T CEO John Stankey said in the statement. “It will support the fantastic growth and international launch of HBO Max with Discovery’s global footprint and create efficiencies which can be reinvested in producing more great content to give consumers what they want.”

The deal underscores the difficulty telecom companies have had finding a payoff from their media operations. Verizon Communications Inc. announced its own plan to slim down earlier this month. The company agreed to sell its media division to Apollo Global Management Inc. for $5 billion, a move that will offload online brands like AOL and Yahoo.

Jason Kilar, a streaming industry veteran who helped found Hulu, has been running WarnerMedia for the past year. At a recent investor conference, he defended the need for the business to be owned by AT&T, saying the telecom company had invested billions of dollars in HBO Max and broken down silos within the company to create a single operating unit. He added that AT&T’s phone and broadband customers were less likely to cancel if they got HBO Max, and many of HBO Max’s subscribers were AT&T customers.

At Discovery, Chief Executive Officer David Zaslav has helped the company grow through acquisitions, including a purchase of HGTV owner Scripps Networks Interactive Inc. in 2018.

Discovery shares experienced a meteoric rally earlier this year, but have lost more than half their value since Bill Hwang’s Archegos Capital Management was forced to liquidate its positions. The shares remained up 18% for the year through the end of last week. That gave the company a market value of almost $24 billion. AT&T, meanwhile, gained 12% in 2021, giving it a market capitalization of $230 billion.

Stankey has been cleaning house at the sprawling telecom titan, cutting staff and selling underperforming assets. The company has been funneling money into rolling out its 5G wireless network, which requires billions of dollars of investment, as well as expanding its fiber-optic footprint.

The carrier has been boosting movie and television production to attract subscribers to its HBO Max streaming service. It also needs cash to pay down debt. AT&T racked up borrowing of $200 billion after an acquisition spree, and though it’s been paying down what it owes, it now has bills from a recent spectrum auction.

AT&T was the second-highest bidder in the Federal Communications Commission’s sale of airwaves, committing $23 billion. Verizon, the top bidder, agreed to pay $45 billion.

The Discovery agreement comes just months after AT&T reached a deal to spin off its DirecTV operations in a pact with buyout firm TPG. AT&T also agreed in December to sell its anime video unit Crunchyroll to a unit of Sony Corp. for $1.2 billion.

And the company has parted with its Puerto Rico phone operations, a stake in Hulu, a central European media group and almost all its offices at New York’s Hudson Yards.

In shedding the assets, Stankey has been unwinding an acquisition spree undertaken by predecessor Randall Stephenson, who spent his 13-year tenure as CEO bulking up the company. Stephenson, who handed the reins to Stankey last year, even kept a color-coded roster of companies he wanted AT&T to buy, leading to 43 acquisitions.

But critics such as activist investor Elliott Management Corp. complained about the strategy, urging AT&T to focus on its core business. AT&T’s mountain of debt also put pressure on the company to cut staff and sell assets.

The Discovery deal represents an admission that AT&T’s audacious plan to build a media and communications conglomerate was a costly misfire.