Nexstar said it would pay $46.50 per share, representing a premium of 15.5 percent to Tribune Media's closing price on Friday. Tribune shares rose 10.5 percent to $44.50.
The value of the deal was in line with what Reuters reported on Sunday, citing people familiar with the matter.
Including debt, the deal is worth $6.4 billion.
The acquisition comes just three months after Sinclair Broadcast Group's $3.9 billion deal to buy Tribune collapsed over regulatory hurdles.
Irving, Texas-based Nexstar said the transaction was subject to approvals by Tribune's shareholders and regulators including the Federal Communications Commission.
The company outbid private equity firm Apollo Global Management with an all-cash offer that values Tribune at around $46.50 per share, three sources had told Reuters.
The deal, expected to close late in the third quarter of 2019, will add about $160 million in the first year to Nexstar's earnings, the companies said.
Nexstar said it had received committed financing for the transaction from Bank of America/Merrill Lynch, Credit Suisse, and Deutsche Bank.
Bank of America/Merrill Lynch the financial adviser and Kirkland & Ellis and Wiley Rein the legal counsel to Nexstar.
Moelis & Co. and Guggenheim Securities are financial advisers to Tribune Media and Debevoise & Plimpton and Covington & Burling are its legal counsel.