CHICAGO (Reuters) - Caesars Entertainment Corp said on Tuesday it has struck a crucial $5 billion deal with most of its casino operating unit’s creditors, resolving billions of dollars in legal claims and paving the subsidiary’s way out of a costly bankruptcy.

Passengers leave the cabin after riding the 550 foot-tall (167.6 m) High Roller observation wheel, the tallest in the world, in Las Vegas, Nevada April 9, 2014. The wheel is the centerpiece of the $550 million Linq project, a retail, dining and entertainment district by Caesars Entertainment Corp. REUTERS/Las Vegas Sun/Steve Marcus

The Las Vegas-based company’s main operating unit, Caesars Entertainment Operating Co Inc, filed in January 2015 one of the most complex U.S. bankruptcies with $18 billion of debt.

The restructuring has been embroiled in a sprawling web of litigation between some of Wall Street’s most aggressive investors.

Junior creditors led by hedge fund Appaloosa Management accused the Caesars parent and its private equity owners Apollo Global Management and TPG Capital Management [TPG.UL] of looting the operating unit of its best assets and leaving it bankrupt.

Under the agreement announced after a week of intense telephone negotiations from New York to Los Angeles, junior creditors will receive about 66 cents on the dollar, up from 27 cents under a previous plan.

The settlement needs to be formalized and approved by the U.S. Bankruptcy Court in Chicago.

“It’s important to recognize that a lot of work needs to be done in the next few weeks. Will there be bumps along the road? Yes. Is this a durable deal? Yes,” said Bruce Bennett, a lawyer for Jones Day representing junior creditors.

Apollo and TPG, which formed Caesars in 2008 through a $30 billion leveraged buyout of Harrah’s just before a U.S. economic downturn, will relinquish their stake in Caesars as part of the agreement.

The settlement came after the judge overseeing the bankruptcy pressed Caesars directors such as billionaire investors Marc Rowan of Apollo and David Bonderman of TPG to contribute to the reorganization in exchange for releases from fraud allegations.

Caesars said the funds’ contribution to the reorganization plan is worth about $950 million but did not specify whether any directors were personally pitching in.

An independent examination led by a former Watergate prosecutor found in March that Caesars and its private equity owners could be on the hook for roughly $5 billion. Junior creditors said they had claims worth up to $12.6 billion.

First-lien bank lenders will recover roughly 115 cents on the dollar, about 1 cent less than previously agreed upon, while first-lien noteholders will still recover about 109 cents on the dollar.

As part of the sweetened deal, junior and unsecured creditors will own a larger equity holding in the new group to be formed through the parent company’s merger with another affiliate, Caesars Acquisition Co.

Apollo and TPG will own about 16 percent of the group to be called “New CEC”, according to regulatory filings.

Shares of Caesars closed 19 percent lower at $7.67. The stock had risen about 45 percent since the company unveiled its settlement offer on Wednesday.

“The agreement reflects the private equity sponsors’ attempt to thread the needle between managing their fiduciary duties (...), reducing litigation risk and maintaining relationships with the creditor community,” said Nathan Flanders, a managing director at Fitch.