(Bloomberg) -- CBS Corp. agreed to merge with Viacom Inc. in an $11.7 billion transaction, capping years of on-again, off-again talks between the U.S. media giants.

The all-stock deal, announced Tuesday, unites the most-watched U.S. broadcast network with the parent of Paramount Pictures and cable channels such as MTV and Nickelodeon. It followed marathon negotiation sessions this week as the two sides hashed out a price for the long-awaited merger.

CBS shareholders will get 61% of the combined company, with the remainder going to Viacom investors. Each Viacom share and will convert into 0.59625 of a CBS share.

Shari Redstone, whose family investment vehicle National Amusements Inc. controls both companies, will become chairwoman of the combined entity. Viacom Chief Executive Officer Bob Bakish will lead the business as CEO.

With the media industry consolidating ever further into a handful of giant companies, the transaction could give the combined entity much greater clout in negotiating deals with pay-TV distributors. It also could help them spread out the cost of content purchases like sports rights over a wider swath of channels.

CBS would receive six seats on the 13-member board, while Viacom would get four. Another two would be designated to National Amusements.

The last time the companies were in merger discussions, more than a year ago, Viacom directors had agreed to take 0.6135 of a CBS share for every nonvoting share of their business, people with knowledge said at the time. The companies, using the code names “Comet” and “Venus,” had expected to save at least $1 billion by combining.

CBS shares have dropped since then. They’ve lost about 18% since the beginning of 2018, as the broadcaster faced mounting challenges, including the ongoing competition for viewers with the likes of Netflix Inc. and the ouster of longtime CEO Les Moonves.

This time around, the negotiations dragged on several days as the two sides worked out the details. The companies held round-the-clock negotiating sessions this week, according to people familiar with the talks.

Previous Talks

CBS and Viacom, both based in New York, were one entity until 2006, when the Redstone family decided investors would give them greater value as separate companies. That strategy didn’t work as well as expected, and there’s been on-and-off-again efforts to recombine them in recent years.

CBS has been weighing its next moves since firing Moonves last September, after a dozen women accused him of sexual misconduct, setting off a shake-up that included a board overhaul. Joe Ianniello, formerly chief operating officer, has been running the company as interim CEO ever since.

CBS and Viacom have ties that go back to the 1970s. The latter was spun out of CBS in 1971, after the Federal Communications Commission ruled that TV networks couldn’t sell programs into syndication after the shows had completed their original run.

Viacom became the vehicle that marketed reruns of “I Love Lucy” and “Gunsmoke,” and attracted the interest of Sumner Redstone as an investment. He acquired control of the company in 1987 and purchased CBS in 1999.

--With assistance from Jeff Green, Gerry Smith and Christopher Palmeri.

To contact the reporters on this story: Nabila Ahmed in New York at nahmed54@bloomberg.net;Ed Hammond in New York at ehammond12@bloomberg.net;Lucas Shaw in Los Angeles at lshaw31@bloomberg.net

To contact the editors responsible for this story: Liana Baker at lbaker75@bloomberg.net, ;Crayton Harrison at tharrison5@bloomberg.net, Nick Turner

©2019 Bloomberg L.P.