Viacom and controlling shareholder Sumner Redstone have come to an agreement on terms of a settlement that would result in the departure of Chief Executive Philippe Dauman, two sources familiar with the situation told Reuters on Thursday.

An announcement is expected to come Thursday night, sources said.

The settlement would end the battle for control over Redstone's $40 billion empire that includes Viacom and CBS, and which has been a source of shareholder angst and months of uncertainty.

It would also conclude the legal battle between Dauman and Redstone in Massachusetts over the CEO's removal from National Amusements Inc, the privately held company that holds Redstone's Viacom and CBS Corp voting shares, as well as the trust that will determine the fate of both media companies when the 93-year-old dies or is deemed mentally incapacitated.

Under terms of the settlement, if finalized, Dauman, 62, will be replaced by Viacom Chief Operating Officer and his longtime right-hand man, Thomas Dooley, who will be interim CEO until Sept. 30, and then may stay on longer, according to the sources, who wished to remain anonymous because the discussions are confidential.

As part of the agreement, Dauman will stay on as executive chairman until Sept. 13 and be allowed to present his plan to sell a minority stake in Paramount Pictures to the Viacom board, the sources said. Dauman will receive about $72 million under the agreement, they said.

Sumner Redstone in May removed Dauman and Viacom board member George Abrams from the Sumner M. Redstone National Amusements Inc Trust. A spokesman for Redstone said the media mogul had been unhappy with the company's performance and about Dauman's plans to sell a stake in Paramount Pictures.

Dauman and Abrams shot back with their own lawsuit to prevent their removal from the trust, arguing that Redstone was being manipulated by his daughter, Shari. Shari Redstone called the allegation "absurd" and said her father made his own decisions.

Redstone also moved to kick Dauman and four other directors off the board in June, sparking litigation in Delaware to block the attempt.

Under the settlement, the board would add the five directors that National Amusements put forward in June. It is unclear when the directors that National Amusements moved to replace will leave the board.

Sumner Redstone's granddaughter, Keryn Redstone, has filed a cross-complaint in connection to that lawsuit, and is planning to proceed with her lawsuit even if there is a settlement, according to a source familiar with the situation. However, that suit is unlikely to affect the removal of Dauman from Viacom and Redstone's trust.

Lucas Jackson | Reuters

The Viacom headquarters in New York.

Since he became CEO in 2006, Dauman has received over $409 million in reported compensation, according to Equilar.

Dauman, who has worked with Sumner Redstone for more than 30 years, gained the title of executive chairman in February, when the media mogul relinquished that role. Shari Redstone had opposed Dauman's elevation to executive chairman.

Shares of Viacom have fallen around 50 percent in the past two years as its cable networks, including MTV and Nickelodeon, suffered from falling ratings because younger viewers were migrating online and to mobile video. Viacom's U.S. advertising revenue has declined for eight straight quarters.

Dauman has tried to turn Viacom around by wooing advertisers with data to better target commercials. Under his leadership, Viacom renewed a multi-year distribution contract with satellite TV provider Dish Network.

But it was Dauman's plans to sell Viacom's stake in Paramount Pictures, which investors cheered, that caused him troubles. Sumner Redstone, who won a long battle with media mogul Barry Diller to acquire the film studio in 1994, opposed the sale.

Despite this, Dauman has pushed on with the potential sale. As Reuters first reported, Chinese real estate and entertainment conglomerate Dalian Wanda Group has held talks with Viacom about acquiring the stake.

Shares of Viacom have risen more than 40 percent since Redstone removed Dauman from the trust on May 20, a move that some investors saw as the first step in a change in management that could eventually lead to a sale of the media company.