There have been so many truly extraordinary twists and turns in the saga of Caesars Entertainment CZR over the past eight years that it’s hard to pinpoint exactly when the whole thing went off the rails. After all, an $18.4 billion bankruptcy filing at one of the biggest gambling empires in Las Vegas tends to result in a lot of finger-pointing. But for symbolism alone, nothing can beat the evening of Nov. 17, 2012.

That was the night that David Bonderman, the billionaire founder of private equity firm TPG Capital, threw himself a 70th birthday party. It made sense for Bonderman to have it in Vegas. He and his wife had planned a lavish celebration with 1,000 of their closest friends. Actor and comedian Robin Williams would serve as the emcee, with music legends Paul McCartney and John Fogerty rocking out. Bonderman had also agreed to make a $1,000 donation in the name of each guest to the charity of his or her choice, and every attendee would receive an iPod filled with the private equity mogul’s favorite tunes. It was the kind of event for which top-tier casinos are made.

And Bonderman just happened to be part owner of one. In 2008, TPG had joined with Apollo Global Management APO , the buyout firm led by former Drexel Burnham Lambert banker Leon Black, to take Caesars private. Four years later, Caesars was straining under its heavy debt load, and the two private equity shops stood to lose the bulk of their $6 billion equity investment. By having his gala at Caesars Palace, the company’s crown jewel, Bonderman could have made a high-profile show of support.

Ceasar's Palace in Las Vegas The pool scene at the Caesars Palace hotel and casino in Las VegasPhotograph by Michael Lewis for Fortune

Instead, Bonderman took his celebration to the Wynn Resort WYNN , Caesars’ biggest Vegas rival.

Everything went off without a hitch—food, liquor, accommodations, entertainment, and limousines. “It was a beautiful evening,” says someone who was there. “Probably spent $7 million to $8 million on this party.”

None of that money went to Caesars, which certainly could have used the revenue. Instead, Gary Loveman, the Caesars CEO, and his management team were left to stew. Their company was then being whipsawed by a fatal confluence of too much debt, an unanticipated overcapacity in the gaming industry, and the aftershock of the 2008 recession, which had forced gamblers to reduce both their casino visits and their wagering. The Caesars execs were stunned by Bonderman’s public snub. “That was a tough pill,” says one today. “It was so demotivating to the people that work here that our principal owner is going to have this big event somewhere else.” (Bonderman declined requests to be interviewed for this story.)

Rank in Fortune 500: 328
Revenues: $8.7 billion
Profits: -$2.8 billion
Employees: 68,000
Total Return to Shareholders
(since IPO, Annual Rate*):

*Feb. 8, 2012 to Dec. 31, 2014.

Today the dysfunctional situation at Caesars has turned into a full-fledged debacle—and has sparked a high-stakes battle between some of Wall Street’s most formidable power players. On one side of the fight are Apollo and TPG, two of the savviest and most successful buyout firms in history. On the other side is a group of equally forceful and highly motivated hedge funds, including the $23 billion Canyon Partners; Oaktree Capital Management OAK , the $100 billion empire co-founded by Howard Marks; Elliott Management, the much-feared $25 billion fund firm led by Paul Singer; and Appaloosa Capital, a $20 billion fund run by David Tepper, who secured his place in hedgie lore when he reportedly pocketed more than $3 billion in 2013.

Caught in the middle is Caesars Entertainment, No. 328 on this year’s Fortune 500. Once the fast-growing star of the gaming industry, Caesars is now a mess—a holding company standing on top of a shifting mix of casino and real estate assets that together lost about $2.8 billion last year, a slight improvement from the year before. Likewise, CEO Loveman, a former Harvard professor who orchestrated the rapid rise of Caesars—formerly Harrah’s, until Loveman greatly expanded and eventually changed the company’s name—has seen his once-pristine reputation tarnished by the decline of the core business and charges by Caesars’ creditors of irresponsible financial management.

The dispute between the buyout firms and hedge funds escalated on Jan. 15, with the aforementioned $18.4 billion bankruptcy filing of Caesars Entertainment Operating Corp., or CEOC, a disparate group of Caesars gambling businesses organized as a subsidiary of Caesars. (Yes, it’s a complex corporate structure.) At issue in the CEOC bankruptcy case is not only who will own the company when it emerges from Chapter 11, but also the fundamental question of whether Apollo and TPG were too creative and aggressive in their efforts to keep Caesars afloat and to salvage their investment, in the process harming creditors, many of which were opportunistic hedge funds that bought up the struggling company’s debt at a discount and expect to cash in.

The stakes are high, and the egos are higher. “It’s all really, really smart guys who like to win, and a lot of dollars behind them,” says Jude Gorman, the general counsel at Reorg Research, a New York City firm that closely follows bankruptcies such as CEOC’s. Professional fees in the bankruptcy case are likely to end up being in the high hundreds of millions of dollars, boosting a lot of bonus pools for years to come.

Linq hote, The High roller, observation wheel, Caesars Caesar Entertainment Resort Properties owns 6 casinos as well as The LINQ promenade which features The High Roller, a 550-feet-tall observation wheel.Photograph by Michael Lewis for Fortune

There’s another reason, too, that Caesars will be one of the most closely watched financial fights in years: schadenfreude. Everyone in the tight-knit community of Wall Street bankers and lawyers wants to see whether mighty Apollo and TPG will finally get a dose of comeuppance. “They were too smart by half, and they just pushed the edge of the envelope too much, and they’re getting called on it,” says one longtime restructuring banker, who believes that a judge will ultimately rule against the buyout firms for, if nothing else, the sheer amount of financial engineering they employed.

Of course, the banker points out, there is another way to look at the situation. “The other side of this is they have fiduciary responsibilities to their investors, and they’re going to do everything they can to preserve value legally and ethically,” he says. “It’s a very legitimate argument.”

Those contrasting views may end up being adjudicated in courtrooms from New York to Wilmington to Chicago. “So the question is,” says the banker, “How far is too far?”

Before there was a Caesars Entertainment, there was a hotshot academic who was eager to test out a thesis. Loveman was a professor at Harvard Business School in the 1990s when he first conceived of a way to develop deeper customer loyalty in service-oriented companies, such as casinos, that he believed could lead to higher revenues and profits. A onetime math prodigy from Indianapolis, Loveman, now 55, had graduated from Wesleyan University before getting his Ph.D. in economics from the Massachusetts Institute of Technology. (His 400-page thesis was about unemployment in advanced countries.) While teaching economics at Harvard, he became fascinated by the idea of improving customer loyalty.

In 1994, Loveman co-wrote an article in the Harvard Business Review,Putting the Service-Profit Chain to Work,” that focused on how companies such as Southwest Airlines LUV , Taco Bell YUM , and Intuit INTU had figured out that by making employees and customers “paramount,” a “radical shift occurs in the way they manage and measure success.” Loveman and his co-authors introduced the idea that “lifetime value of a loyal customer can be astronomical.” The article led to consulting gigs. Loveman was suddenly much in demand.

One of Loveman’s consulting assignments was for Harrah’s Entertainment, a Memphis casino company with its headquarters then in an antebellum mansion. At first the conservative gambling executives resisted Loveman’s suggestions. But Loveman was convinced that the gambling industry, armed with piles of data that casinos collect on their customers’ habits, would be the perfect testing ground for rewarding the most valuable ones with perks—free meals, tickets to shows, room upgrades—in order to cement their loyalty. He wrote an unsolicited letter to Philip Satre, Harrah’s CEO, outlining his thinking.

Satre was won over. In 1998 he brought in Loveman as Harrah’s chief operating officer with a mandate to implement his customer-loyalty plan. It was meant to be a two-year job—a glorified experiment. The next year Harrah’s moved its corporate headquarters to Las Vegas. (It would be several more years before the company’s name was changed to Caesars.) Loveman started commuting by private jet between Boston and Las Vegas.

In his new role, Loveman threw himself into developing what became Total Rewards, Harrah’s version of a customer-loyalty program. Since Loveman knew that gamblers tended to be attracted to the newest and plushest casinos—and upstart Harrah’s couldn’t afford that battle—the idea was to reward them with perks, often in real time, based on how profitable the customers were to the casino. “We want to know not only what you’re worth,” says Loveman, “but what you could be worth, and we want to treat you consistently with that.”

The program was a brilliant idea that helped to transform Harrah’s into the world’s dominant player in the gaming industry. “I wasn’t surprised that it worked, but I was surprised at how well it worked,” Loveman tells Fortune.

In fact, Total Rewards was such a big hit that when Satre retired in 2003, Loveman was the obvious candidate to succeed him as CEO. Under Loveman, Harrah’s quickly went from being a second-tier company that operated 26 casinos to an industry leader.

Loveman fueled this rapid growth by going on an acquisition spree and implementing the Total Rewards program across all the new casinos. In 2004, for example, he bought the World Series of Poker and three casinos from Binion’s Horseshoe for $1.5 billion; the next year he bought the Imperial Palace, in Las Vegas, for another $370 million. Most significant, ultimately, was his 2005 purchase of the former Caesars Entertainment for $9.3 billion.

This expansion strategy yielded impressive results. The company’s revenues and operating income grew to nearly $10.8 billion and $1.7 billion, respectively, in 2007, from $4.1 billion and $780 million, respectively, in 2002. When Loveman started at Harrah’s in 1998, the stock had traded at around $22 a share. By the end of 2005, it was trading above $70.

Loveman believed that the stock could trade higher. And he was bothered by a market discrepancy. Loveman had noticed that casino companies traded at lower multiples of their Ebitda—or earnings before interest, taxes, and other factors, often used as an approximate measure of operating cash flow—than did hotel companies, even though gaming companies often owned many high-end hotels. “It seemed like that had been true since Moses came down with the tablets, and I couldn’t figure out why that should be,” says Loveman.

So the CEO made a fateful decision. He began talking to David Bonderman about the possibility of splitting Harrah’s hotel assets into a separate, publicly traded real estate investment trust, or REIT, as a way to try to capture more value for shareholders, figuring the private equity chief would know what to do.

By 2006 another plan was being hatched. Bonderman suggested to Loveman an alternative to the REIT: a full-fledged leveraged buyout of the company. TPG had recently raised a $15 billion fund, and Bonderman was eager to put the money to work. Loveman encouraged Bonderman to talk to the board of directors. At the time Harrah’s was leveraged at just four to one—it had $11 billion in debt—and had the industry’s only investment-grade balance sheet. Given the company’s growth trajectory, Loveman saw the potential to add leverage, shrink the equity, and get richer. “I thought you could create a lot of value that way,” Loveman says.

David Tepper-Appaloosa, Paul Singer- Elliot Management, Marc Rowan-Apollo, David Bonderman- TPG From left: Hedge fund honchos David Tepper of Appaloosa and Paul Singer of Elliott Management have made money trading Caesars; buyout specialists Marc Rowan of Apollo and David Bonderman of TPG have spent years trying to limit the losses on their investment.Photos: Tepper and Bonderman: Andrew Harrer—Bloomberg via Getty Images; Singer: Jacob Kepler—Bloomberg via Getty Images; Rowan: Phil McCarten—Reuters

Loveman then received a call from Marc Rowan, one of the three founding partners of Apollo and a financier who stands out, even on Wall Street, for both his incandescent intellect and his ample self-confidence. Rowan and his team had spent six months poring over Harrah’s financials, studying the Total Rewards program and visiting casinos. He wanted to meet Loveman. Over dinner in New York, Rowan presented his own ideas for taking Harrah’s private.

No surprise, Rowan had spotted the same valuation anomalies between casino companies and hotel companies and thought Apollo could capture that arbitrage. He was also attracted to Harrah’s growing free cash flow—it doubled to more than $1 billion between 2005 and 2006—and the growth model that Loveman had created. “He is very mathematical and had built a better mousetrap,” says Rowan. Their dinner lasted nearly two hours. Loveman told Rowan the same thing he had told Bonderman: Talk to the board.

Eventually, with a nudge from Loveman, Apollo and TPG decided to work together and made a series of buyout offers. In December 2006 an independent committee of Harrah’s board of directors agreed to sell the company for $90 a share, a 35% premium compared with where Harrah’s stock was trading before their initial bid. The deal was valued at $30.7 billion, including the assumption of Harrah’s $10.7 billion in debt, making it the fourth-largest buyout ever at the time. By then, Harrah’s owned 51 casinos in North America and overseas.

Some directors were wary of adding a huge pile of debt on the company and were not particularly excited about giving up their long-held Harrah’s board seats. “But when you got a company that’s selling at $66 per share and somebody’s going to give you $90 in cash, it’s really, really hard to say no,” Loveman says.

Loveman’s stock and options in Harrah’s were worth $95 million on a pretax basis. He could have cashed out and moved on. But he decided there was more to accomplish—and more money to be made—with Bonderman and Rowan at his side. He won’t say specifically how much of his $95 million he rolled over into the new deal but says it was less than half. “It was a big number,” he concedes. (The exact breakdown of the investors’ $6.1 billion buyout equity account has never been made public either, and a spokesman for the company declines to do so.)

TPG and Apollo decided to structure Harrah’s as a holding company with two wholly owned subsidiaries. One was the so-called operating company, which was given 45 properties and casinos along with $18.7 billion of bank debt and bonds. The other was a real estate company, with six casinos in Nevada and one in Atlantic City, financed with $6.5 billion of mortgaged-backed securities.

Even though the deal was announced in December 2006, it did not close until more than a year later, in late January 2008. In large part the delay came from the lengthy background checks that the gaming regulators conducted on the private equity partners at Apollo and TPG. “They talk to your friends, they talk to your family, they interview your neighbors,” Rowan recalls. “They have the right to come to your home and open your safe.” The conventional wisdom at the time, says Rowan, was that no private equity firm could ever endure the lengthy and invasive regulatory-approval process necessary to be licensed. Rowan was anything but daunted, however. The cocksure buyout specialist embraced the deal’s complexity and its high regulatory hurdles as a wonderful opportunity.

Ceasar's Palace in Las Vegas A replica of Michelangelo’s David in the Appian Way shopping area inside Caesars Palace.Photograph by Michael Lewis for Fortune

But through their utter self-assuredness, the masters of the universe at Apollo and TPG were sowing the seeds of the deal’s demise. They had unwittingly piled on billions in debt at Caesars at the very moment the economy was about to go into free fall—taking the company’s cash flow down with it. In seeking to maximize their potential return, they managed to defy a Vegas truism: “The house always wins.” In this case, the house was mortgaged to the hilt.

Although in hindsight the purchase price of around 10 times Ebitda that Apollo and TPG paid was clearly too high, Rowan at first disputes that they paid too much. “Did we?” he asks. “Why? Why do you say that? Because other people have written that?” It looked great on paper, he explains: Harrah’s was the largest landholder on the Las Vegas strip. The partners were getting not only Harrah’s existing cash flow but also new properties for which the money had already been spent. “It was an unbelievable time,” Rowan says. “Markets were roaring. Las Vegas visitation was great.” But ultimately he concedes the obvious: Apollo and TPG overpaid.

By the time the deal was about to close, Loveman remembers that it was “a bit uncertain” as to whether every bank would honor its commitment. But they did. “Almost everything that happened after that was not as good,” Rowan says.

For starters, the financial performance for most of 2008 was not quite what had been forecast. “But no one was running around with their hair on fire,” Loveman recalls. That would come during the fall, when the most acute phase of the financial crisis hit. Revenues suddenly plunged 20%, and “play levels” of more affluent customers fell sharply. “So a guy who had $20,000 on a hand at blackjack was still there on $10,000 a hand,” says Loveman. “But that’s half the revenue for me.”

Compounding the problem was the failure of both the buyout firms and company management to account for the explosion of new competitors. That was especially true near Atlantic City, where Loveman’s company was the dominant player with four separate casinos—Caesars, Bally’s, Showboat, and Harrah’s—out of 11 in the market. Dozens of gambling venues had opened in Connecticut, Pennsylvania, New York, Delaware, and Maryland, and Atlantic City took a major hit. Whereas in 2007 Caesars made approximately $550 million in Ebitda from its four casinos in Atlantic City, that number these days is closer to $100 million from three casinos. (Loveman closed one of the four in 2014.) “If Atlantic City had only gone down by, say, one-third, we wouldn’t be where we are right now,” says Loveman.

Both Loveman and Rowan could go on and on—and, in fact, they do—about all the reasons that the business fell off the cliff in the fourth quarter of 2008. But the bottom line is that the numbers had turned against them. What had been $2.8 billion in Ebitda in 2007—with an expectation that it would grow to $4 billion by 2012—became $1.8 billion in 2008 instead. “So now what was seven or eight times leverage is all of a sudden 13, 14 times leverage,” Loveman says. “Holy shit.”

Adds Rowan: “No one wanted an exit at the beginning of 2008.” But by the end of the year that view had changed.

What Apollo and TPG could have done at that point—what many other private equity firms have done—is to fold. They could have conceded defeat, turned the company over to its creditors, and written off their investments. But that, Rowan insists, is not the Apollo way. “We are in the business of owning our decisions, good and bad,” he says. “Sometimes getting some of your investors’ money back vs. zero is a good thing.”

While TPG continued to have meaningful input, Apollo took the lead in the restructuring process. Desperate to lose as little as possible, Rowan and his team went into overdrive. (TPG declined to make any of its partners available for interviews for this story.) The first step was to undertake a voluntary exchange offer during the fall of 2008, in which Caesars paid its junior creditors around 88¢ on the dollar for their existing debt and issued them new debt with a longer maturity and a higher interest rate. As a result, by early 2009, Caesars had reduced its debt by $5 billion. It was not nearly enough.

But Rowan was just getting started. What followed the voluntary exchange offer was a series of more than 50 mind-numbingly complex transactions—involving everything from shifting assets repeatedly from one mostly owned subsidiary to another, to the conversion of junior debt owned by hedge fund manager John Paulson into equity at the holding company, to the purchase of an Israeli mobile-gaming company to try to replace some of the revenues lost in the casinos. Newly affiliated companies were created, and assets shifted among them.

Looking back on this period, Loveman still seems a bit shell-shocked as he recounts the blizzard of transactions that Rowan orchestrated. Each one was designed to buy time until business improved. But moving assets around as if in a glorified game of three-card monte wasn’t nearly as much fun as growing the Total Rewards program. “None of us imagined this is what we would find ourselves doing,” says Loveman.

In November 2010, perhaps hoping to change the subject, the company announced that it was changing its name from Harrah’s to Caesars Entertainment.

Possibly the most surprising financial move of all came a couple of years later when Caesars finally pulled off an IPO. It was hardly the jackpot that its private equity investors had envisioned when they initially took the company private. In February 2012, the holding company—which at the time owned the now-bankrupt CEOC and the real estate company—raised $16.3 million in a tiny initial public offering of less than 2% of its shares. The idea was to create a public float for the stock, to show that there was equity value around and to be able to use those shares for future debt-for-equity exchanges, if need be. On its first trading day, the price soared 71%, valuing the holding company’s equity at close to $2 billion. Since then Caesars Entertainment has completed two more primary sales of equity, raising around $200 million. (The stock recently traded just below its $10 IPO price, giving it a market value of around $1.4 billion.)

Despite all the maneuvering, Rowan knew Caesars still needed more “runway” to avoid crashing under its hefty debt load. So in 2013, Caesars embarked on a series of asset sales designed, Rowan says, to try to create as much time and value as possible for shareholders. “I’ll never shy away from financial engineering,” says Rowan proudly.

To start with, the company changed the name of its real estate subsidiary to Caesars Entertainment Resorts Properties. It then had CEOC—the company now in bankruptcy—sell to its real estate sibling two new, noncasino properties in Las Vegas, including the Linq, a retail, dining, and entertainment development that now has the largest Ferris wheel in the world, for consideration of around $133 million. Also in 2013, Rowan oversaw the creation of a new, separate subsidiary called Caesars Growth Partners. This new entity then bought a total of six properties from CEOC for more than $2 billion in cash.

Ceasar's Palace Las Vegas. High Roller observation wheel A view of Vegas from the top of the High Roller observation wheel at The Linq, a Caesars-owned hotel and casino.Photograph by Michael Lewis for Fortune

That left three separate companies, under the holding company, that all contained casinos and other assets that at one time or another had been part of Harrah’s. “Although controversial, these transactions sought to extend runway,” CEOC would later concede in its bankruptcy filing documents.

None of the assets were put up for sale in a formal arm’s-length auction. That’s because Caesars’ management wanted to keep all the casinos inside the Total Rewards network. But, Rowan argues, the prices paid were fair. Or at least reputable Wall Street investment banks, such as Lazard LAZ , Evercore EVR , Perella Weinberg, and Moelis & Co. MC , declared them fair, for a fee.

In November 2013, Caesars Growth Partners completed a rights offering that allowed the existing shareholders of the holding company to buy equity in it. Apollo and TPG each bought $250 million of the equity, and other investors bought $700 million. The heavily negotiated deal raised $1.2 billion for Caesars Growth Partners and gave the new investors a 42% stake in it; the balance of the economic interest—58%—continued in the hands of the holding company. “We try not to throw good money after bad to save our reputation,” Rowan says. “We allow the companies to do what they are doing, but if we see an opportunity to make an investment that is a win-win, that is great.”

Meanwhile, the situation was getting dire at CEOC. The second half of 2013 was a disaster. Las Vegas was still struggling to recover. Atlantic City was getting decimated. Regional gambling remained weak. When Loveman shared with the board of directors his 2014 budget, the reality set in. The time had come for a new plan. “We had done everything we could to help the company and preserve value,” says Rowan. It was time to give up on Band-Aids and pursue a “complete fix.”

Apollo and TPG decided to see if they could cut a restructuring deal with Canyon and Oaktree, the biggest holders of CEOC’s junior debt, which had declined significantly in value as the company’s prospects deteriorated. (It traded as low as 10¢ on the dollar and now trades around 20¢.) Rowan told them, essentially, We got a problem, you got a problem. The company was going to violate covenants and might not make it.

Worse, CEOC’s auditors were threatening to give the company a “qualified opinion” that would mark Caesars as unable to continue as “a going concern.” Missing a covenant was “a curable” default, Rowan says, but a “qualified opinion” from the auditor was not and would lead quickly to a bankruptcy filing. CEOC had three choices: accept the auditor’s “going concern” opinion and file for bankruptcy in the spring of 2014; negotiate an exchange offer with Canyon and Oaktree and others; or raise more equity to pay off the looming debt maturities and satisfy the covenant defaults.

What followed was a four-month negotiation with Canyon and Oaktree, led by Apollo, to reach new terms with the junior creditors. (Both Canyon and Oaktree declined to comment about their debt positions in CEOC or their involvement in any other part of the Caesars corporate family.) Such out-of-court negotiations are typical in busted LBOs but rarely succeed. This time was no different. The proposed exchange offer failed.

Knowing now that CEOC was probably insolvent and bankruptcy surely inevitable, says Rowan, management decided that it needed to raise enough capital to satisfy its senior debt holders. That would buy it enough time to enter Chapter 11 in an organized way. This plan resulted in the controversial sale of another four casinos from CEOC to Caesars Growth Partners for net proceeds to CEOC of $1.8 billion, which has been earmarked to repay the senior bank creditors at 100¢ on the dollar.

The plan also called for the holding company’s original guarantee of the principal and interest payments on the subsidiaries’ debt to be released, a move that was also extremely controversial. Special committees were set up. Investment bankers were hired, and fairness opinions were written. Says Stephen Cohen, a managing director at Teneo Strategy, CEOC’s public-relations firm, who is sitting with us in Rowan’s palatial office overlooking Central Park: “This is where we start to get angry people.”

By this time most of Caesars’ debt was held by hedge funds, not banks. And even as the rhetoric on both sides spiraled, the contest between the hedgies and the buyout guys began to take on a “just business” feel reminiscent of the Warner Bros. cartoons featuring Ralph E. Wolf and Sam Sheepdog, in which the two adversaries exchange pleasantries each day before punching into the same time clock and attempting to bash each other’s heads in.

The junior creditors at CEOC—Canyon, Oaktree, and others—were apoplectic that the senior creditors were paid off at par while their debt was trading for pennies. They accused CEOC, Loveman, Apollo, TPG, and everyone else they could name of stripping the assets from CEOC, selling them at fire-sale prices, and then using the proceeds to pay off the senior creditors.

In legal bankruptcy parlance, this claim is known as a “fraudulent conveyance” and, if proved, could result in an unwinding of the transactions in question and a restoration of the way things were before the deal occurred. (Such unwinding rarely happens; instead, additional value is given to junior creditors to compensate them for their perceived losses.) Rowan counters that everything was done properly and says that the board was well aware that the asset sales were being carefully monitored.

Canyon and Oaktree tried to enjoin the transaction by asking the regulators to disapprove it. But the deal closed, the money changed hands, and the senior bank holders got the proceeds or a pledge of them.

Then all hell broke loose. The lawsuits started flying. In an August 2014 complaint, Wilmington Savings Fund Society WSFS , the indenture trustee for one tranche of CEOC’s senior secured notes, accused many of the corporate and individual players in the buyout, including Bonderman, Rowan, and Loveman, “of a series of self-dealing transactions” with a purpose of enriching the holding company and its shareholders “at the expense of CEOC and to move CEOC’s assets beyond the reach of CEOC’s creditors.”

The lawsuit accused the defendants of creating a “Good Caesars” and a “Bad Caesars.” “Only the ‘Bad Caesars’ remains liable for the vast majority of the debts incurred in the 2008 buyout transaction,” the lawsuit argued. The next morning CEOC filed a lawsuit against Wilmington Savings.

A separate lawsuit, by UMB Bank UMBF , another indenture trustee, was more pointed. “This is a case of unimaginably brazen corporate looting and abuse perpetrated by irreparably conflicted management,” the suit began. UMB put the extent of the “shameless giveaways” from CEOC to other affiliated entities at “more than $4 billion.” Like Wilmington Savings, UMB wanted the transactions reversed and the assets restored to CEOC.

On Dec. 15, 2014, CEOC skipped a $225 million interest payment on $4.5 billion of its junior debt—the first time the company had failed to make a scheduled interest or principal payment. CEOC said it was taking advantage of a “grace period” on the payment, even though it had more than $1.5 billion in cash on its balance sheet. Four days later CEOC announced that it had reached an agreement with some of its senior creditors under which it agreed to file for bankruptcy in a month’s time and never to pay the interest due to the holders of its $4.5 billion of junior debt or to pay any of its principal.

This was a step too far for Appaloosa’s Tepper and the other holders of the CEOC junior debt. On Jan. 12, 2015, the junior creditors of CEOC, led by their respected attorney Bruce Bennett at Jones Day, filed an involuntary-bankruptcy petition against the company in Chancery Court in Delaware. At the same time, Bennett filed a motion in Delaware for an examiner to be appointed to investigate the more than 50 transactions that Apollo, TPG, and Caesars management had undertaken since September 2008. “All were transacted under the cloak of secrecy, with little or no disclosure of material facts, and without any apparent attempt to market test their value,” Bennett wrote.

CAE.06.15.Caesars.Graphic Photograph by Michael Lewis for Fortune
Click to enlarge.

Court-appointed examiners have become common in big, complex bankruptcies as a way to try to figure out what happened and whose ox was gored. But examiners are expensive and can delay the proceedings. The examiner in the Lehman Brothers bankruptcy received around $50 million for his 13 months of work and that of his law firm.

Three days later CEOC filed a voluntary-bankruptcy petition in Chicago. The company said it wanted to proceed with its previously disclosed restructuring, which it said had the support of at least 80% of its first-lien noteholders. CEOC’s plan called for the long-hoped-for split of Caesars into an operating company and a publicly traded REIT, which would own a new real estate company, and called for the elimination of nearly $10 billion of CEOC’s $18.4 billion of debt by issuing creditors new debt with a face amount of $8.6 billion. Annual interest expense would be reduced to $450 million, from $1.7 billion.

The proposal was contingent on the successful completion of one more bit of Rowan-inspired financial engineering: the $3.5 billion merger of the Caesars Growth Partners business with Caesars Entertainment, the publicly traded parent company. The merger would allow Caesars Entertainment to get its hands on nearly $1 billion of Caesars Growth Partners cash and to help fund the proposed plan of reorganization.

Where this all ends up is anybody’s guess. On March 25, the Chicago bankruptcy judge appointed Richard Davis, a former Watergate prosecutor and Weil Gotshal attorney, to be the examiner with a mandate to uncover whether there was “any apparent self-dealing or conflicts of interest involving” CEOC. Davis said he would charge $850 an hour for his services, a discount of $100 per hour off his usual fee.

Other than the lawyers and M&A bankers, the only real winners in the Caesars fiasco so far are David Tepper of Appaloosa and Paul Singer of Elliott Management. Both investors have made money on their Caesars bets. Tepper did so by buying the CEOC junior debt at its nadir late last fall and watching as it has traded up. Singer profited by buying credit-default swaps on CEOC’s bank debt, which have reportedly risen nearly 60% in value as the restructuring negotiations unfolded.

As for Loveman, he’s had enough. In early February, he announced that he would step down as CEO on July 1. Mark Frissora, the former CEO of Hertz, will replace him. Loveman will remain chairman of both Caesars Entertainment and the bankrupt CEOC. He concedes that he’s burned out. The ordeal has taken its toll. “I want to go do something else,” says Loveman. “I won’t work in the casino business again. I’d like to do something completely different.”

Loveman says he’s left to contemplate one burning question: “How do you prepare yourself for events that are awfully hard to predict?”

Rowan, on the other hand, says he has remained “Zen” throughout the process. At best, he says, Apollo might recover half its investment. But Rowan has no intention of giving up the fight. “People can like or not like Apollo, but we are tenacious,” he says. “We dig in, and we try to fix the problems.”

Part of what must stick in the craw of the junior creditors at CEOC is that, after all the years of financial finagling, Apollo and TPG have managed to retain a portion of the value of their original investment. With their combined ownership stake of 60.6% in Caesars Entertainment plus their stake in Caesars Growth Properties, Rowan says Apollo values its original equity investment at 20¢ on the dollar. That’s about where CEOC’s junior debt trades too, making for an unusual dynamic: It is rare for an equity investor in a failed LBO to potentially receive the same recovery as a group of junior creditors. If any creditor gets less than 100% of his principal back, the equity generally gets wiped out. For that reason alone, the Caesars deal will be talked about for years in the buyout world.

But, of course, few disastrous LBOs of this magnitude have had a salvage crew as savvy and dedicated as Rowan and his team. Now, Rowan says, there simply is no value left for CEOC’s junior creditors. It’s not personal, he explains, it’s just the way the math works. The junior creditors, of course, disagree. “The reality is they are out of the money,” says Rowan. What they proposed, he says, was a “one-sided exchange transaction,” which Caesars rejected in order to have a chance for a more organized restructuring.

Where then does that leave the contest of the century between the best and brightest players in private equity and the world’s savviest distressed hedge fund investors? The final outcome will be seen after either litigation or tough negotiations, or both. Meanwhile, some hard lessons have been learned. Namely, that the most sophisticated financial engineering on Wall Street is useless if your core business collapses.

Besides Tepper and Singer, Rowan believes, everyone has lost money. “There are no geniuses now at Apollo and TPG,” he concludes.

A version of this article appears in the June 15, 2015 issue of Fortune magazine with the headline ‘Losing Las Vegas.’