Gray Television Inc. is buying Meredith Corp.’s broadcast stations for $2.7 billion, adding 17 mostly Fox and CBS affiliates to its portfolio.

The all-cash transaction is structured as a spinoff of Meredith’s magazine group as a separate company, which will retain the Meredith name and ticker symbol, with the old Meredith sold to Gray, Meredith said. The purchase confirms an earlier Bloomberg News report.

The sale will allow Meredith to focus on its magazine division, which publishes titles such as Better Homes & Gardens and People, and boost its digital strategy.

“We expect the transaction to unlock meaningful shareholder value as it advances all of the company’s financial priorities: reducing net debt, improving financial flexibility, allocating capital to fast-growing digital and consumer opportunities, and providing returns to shareholders,” Meredith Chief Executive Officer Tom Harty said in the statement.

Meredith’s stations include affiliates of Fox and CBS in cities such as Atlanta, Las Vegas and Portland, Oregon, according to its most recent annual report. The roster also includes a few other network affiliates and independent stations. The division contributed 27% of its revenue in its most recent fiscal year.

Meredith shares jumped as much as 13% to $35.22 in New York trading. They have risen 62% in the first four months of the year, giving the company a market value of about $1.4 billion. Gray Television shares, about unchanged Monday, added 14% through April, while the S&P 500 Index climbed 11%.

The mergers-and-acquisitions market has been ripe for local television properties, which generate a lot of cash and operate in a highly fragmented industry.

Gray has been building up its portfolio of stations in recent years through acquisitions. Buying Meredith’s stations represents its largest deal since 2018, when it bought closely held Raycom Media Inc. for $3.6 billion, according to data compiled by Bloomberg.

In April, it said it would sell some the stations it acquired from Quincy Media Inc. earlier this year to Byron Allen’s Allen Media group.

Moelis & Co. acted as financial adviser to Meredith, while BDT & Co. served as financial co-adviser and Lazard served as a strategic adviser.