CBS Corp. has settled its Delaware Court of Chancery lawsuit against controlling stockholder National Amusements Inc., saying Monday that the company would put aside $120 million to pay former CEO Leslie Moonves, pending the outcome of an investigation into allegations that he had sexually harassed women during his time at the network.

The settlement, announced Sunday afternoon, avoids a planned trial in CBS' dispute with Shari Redstone and her family's National Amusements holding company, which was set to begin in three weeks.

As a part of the agreement, CBS said Moonves had resigned from his role as chairman and CEO, and both the company and its former top executive would donate $20 million to organizations that support the #MeToo movement and equality for women in the workplace.

In a statement Sunday, CBS said that it had agreed to rescind a stock dividend that sought to dilute National Amusements' voting control of the New York-based broadcaster, amid fears that Redstone was pursuing a merger with Viacom Inc. National Amusements, meanwhile, confirmed that it had no plans to force a merger with Viacom, and agreed not to propose a recombination of the sister media companies for at least two years, CBS said.

After that period, a majority of CBS' 11 independent directors would need to approve a CBS-Viacom deal.

CBS also announced in a regulatory filing Monday morning that it would place $120 million in a trust to pay Moonves if the board determines that his termination was not for cause. The decision would come no more than 30 days after attorneys from Covington & Burling and Debevoise & Plimpton conclude an independent investigation of the allegations against Moonves, which were detailed in an article published in The New Yorker magazine in August.

If the board finds that CBS was entitled to fire Moonves for cause, the funds would be distributed to the company, and CBS would owe no further obligations to Moonves, CBS said. According to the filing, a final determination would come no later than the end of January.

Moonves has denied allegations of sexual misconduct and retaliation against women in the workplace.

The parties also announced on Sunday changes to the CBS board, including the departure of five independent directors and one director who had been aligned with National Amusements. The new 13-member board includes 11 independent directors and two affiliates of National Amusements, which previously had three designees within CBS' corporate governance structure.

Joseph Ianniello, who had served as CBS' chief operating officer, was named president and acting CEO while the board searches for Moonves' permanent replacement. The chairman position would remain open in the interim, CBS said.

“Today's resolution will benefit all shareholders, allowing us to focus on the business of running CBS—and transforming it for the future,” Redstone said in a statement on Sunday. “We are confident in Joe's ability to serve as acting CEO and delighted to welcome our new directors, who bring valuable and diverse expertise and a strong commitment to corporate governance.”

Bruce Gordon, the lead independent director on the CBS board, thanked Moonves for his 24 years with CBS, but said the settlement—and the CEO's resignation—were in the best interest of the company.

“This agreement maintains an independent board that is charged with determining the best course for the future of CBS on behalf of all shareholders,” he said.

Sunday's settlement put to rest a bitter legal battle in Delaware for control of the media giant, which pitted Moonves against Redstone, a 64-year-old media executive who rose to power as vice chair of CBS and Viacom in 2016, after a power struggle at Viacom resulted in the resignation of her father, Sumner Redstone.

CBS had sued National Amusements on May 14, accusing Redstone of actively trying to undermine the company's management team by pursuing a merger of Viacom and CBS, which are both controlled by the Redstone family and National Amusements. Three days later, the CBS board voted 11-3 to approve a special stock dividend that aimed to dilute Redstone's and National Amusements' 80 percent voting stake in the company to around 20 percent.

Redstone and National Amusements argued that the move was invalid under Delaware law and that it had been blocked by a pre-emptive measure amending CBS' bylaws to require 90 percent of the CBS directors to approve board actions that would threaten Redstone's control.

Sunday's settlement removed the supermajority requirement and barred any stock issuances, unless notice is provided to all directors 10 days before the board meets to consider the proposals.

Redstone had also targeted Moonves in her own lawsuit against CBS, accusing the executive of orchestrating an “unprecedented” maneuver to wrest voting power away from the company's controlling stockholder.

“The only cogent, but manifestly improper, explanation for the director defendants' unprecedented action is that Leslie 'Les' Moonves, CBS's longtime CEO, has tired of having to deal with a stockholder with voting control and has taken particular umbrage that the exercise of such stockholder's control has migrated from Sumner Redstone to his daughter,” her Cleary Gottlieb Steen & Hamilton and Potter Anderson & Corroon attorneys wrote in a May 29 complaint.

Chancery Court Chancellor Andre G. Bouchard had scheduled a five-day trial to begin in Wilmington Oct. 3.

However, the ordeal was further complicated after The New Yorker's Ronan Farrow published a 9,000-word expose on July 27 detailing allegations by six women that Moonves had engaged in a pattern of abusive behavior and used his position to threaten women into silence. On Sunday, Farrow reported that six more women had accused Moonves of sexual assault or harassment, as media reports circulated that CBS was negotiating the terms of Moonves' departure and a settlement with National Amusements.

In a statement to The New Yorker, Moonves acknowledged three of the incidents, but said they were consensual. He declined to specify which three encounters he considered consensual, according to the report.

CBS in August announced that former federal prosecutors Nancy Kestenbaum of Covington and Mary Jo White of Debevoise would lead an independent probe of the allegations against Moonves. The investigation remains ongoing.

The Chancery Court case was captioned In re CBS Corp. Litigation.

Redstone and National Amusements were represented by Meredith Kotler, Victor L. Hou, Roger A. Cooper, Rahul Mukhi and Mark E. McDonald of Cleary Gottlieb and Matthew E. Fischer, Michael A. Pittenger and Jacqueline A. Rogers of Potter Anderson.

CBS was represented by Theodore N. Mirvis, Jonathan M. Moses, Carrie M. Reilly, Ryan A. McLeod, Claire E. Addis and Cecilia A. Glass of Wachtell, Lipton, Rosen & Katz. Ross Aronstam & Moritz's David E. Ross, Bradley R. Aronstam, Garrett B. Moritz, S. Michael Sirkin and Roger S. Stronach acted as local counsel.