Hedge fund Standard General LP said it has struck a deal valued at $5.4 billion to buy TV broadcaster Tegna Inc., ending years of takeover talks.

Standard General will pay $24 in cash for each outstanding share of Tegna, representing a 39% premium to the stock’s closing price on Sept. 14, before news reports of a possible offer pushed shares higher. The companies valued the deal at $8.6 billion, including debt.

Standard...

Hedge fund Standard General LP said it has struck a deal valued at $5.4 billion to buy TV broadcaster Tegna Inc., ending years of takeover talks.

Standard General will pay $24 in cash for each outstanding share of Tegna, representing a 39% premium to the stock’s closing price on Sept. 14, before news reports of a possible offer pushed shares higher. The companies valued the deal at $8.6 billion, including debt.

Standard General owned 4.8% of Tegna as of the end of last year, according to securities filings.

Shares of Tegna rose 7% in morning trading on Tuesday to $22.40 a share.

Tegna owns 64 U.S. TV stations in 51 different markets. It also owns the True Crime, Twist and Quest networks.

The deal is also backed by private-equity firm Apollo Global Management, which will hold an unspecified amount of nonvoting shares in the Standard General-owned entity buying Tegna. Apollo, which had years ago held talks to buy Tegna as it pushed to expand in broadcast media, owns a majority stake in Tegna rival Cox Media Group.

Once the deal closes, Standard General’s founding partner Soo Kim will become chairman of Tegna. Deb McDermott, a Standard General executive and the former chief operating officer of Media General, will become chief executive officer of Tegna.

“We believe TEGNA has a strong foundation and exciting prospects for continued growth as a result of the stewardship of the Board and the current management team,” Mr. Kim said in a statement.

The deal is expected to close in the second half of this year, but if regulatory clearance of the transaction takes longer, Tegna shareholders will also receive a “ticking fee” on top of the deal price.

Upon closing of the deal, Cox will acquire Tegna’s stations in Austin, Texas; Dallas, and Houston, Standard General and Tegna said.

The takeover comes after talks of buyouts have swirled around Tegna for years. Rival bidders have included media mogul Byron Allen and fellow broadcaster Gray Television Inc., the Journal previously reported.

The deal with Standard General follows the hedge fund’s effort to nominate four candidates to Tegna’s board in 2020 and it later pushed for changes at the company.

Standard General, founded in 2007, has built activist positions in various ailing companies, including RadioShack Corp. in 2015.

More recently, the firm has been buying up casinos through its entity, Twin River Worldwide Holdings, which bought the rights to the Bally’s name and renamed itself Bally’s Corp. Last month, Standard General made an offer to buy the shares of Bally’s it doesn’t already own in a roughly $2.07 billion deal.

Write to Will Feuer at will.feuer@wsj.com