Jamie Dimon’s odd idea of a “favor”

FORTUNE — It looks like Jamie Dimon is trying to rewrite Wall Street history. The brash chief executive of JP Morgan shocked an audience of academics and financial dilettantes at the Council on Foreign Relations in Washington on Wednesday when he blurted out that he did the Federal Reserve “a favor” for acquiring troubled broker-dealer Bear Stearns in 2008. Playing the victim, the normally tough Dimon went on to say that the Bear acquisition had cost JP Morgan between $5 billion and $10 billion and that it was a “real close call,” as to whether he would do the deal again.

Wait, what? How could what was thought of at the time as the steal of the century suddenly be cast as a dud deal? Was Bear really a noxious mélange of unsellable assets? Or, was Dimon engaging in some classic skullduggery?

First off, let’s roll back the tape to those fateful days in March of 2008. The Federal Reserve gathered the chieftains of Wall Street to ask for help in saving Bear Stearns from bankruptcy. The firm had seen its capital cushion eaten away as their clients and trading partners refused to do business with them, fearing that the firm was insolvent. Bear got itself into trouble because it created, sold and held on to billions of dollars’ worth of complex securities that were made up primarily of slices of dodgy mortgage loans. As the credit market seized up, people didn’t want to buy these mortgage pizzas anymore, pushing their value down considerably.

Bear had around $350 billion in assets of which a large chunk, $210 billion, was seen as “toxic.” In March the jig was up, people were so worried that Bear would eventually lose so much money holding those toxic securities that they turned their backs on the firm and ran for the hills. But right before Bear fell flat on its face, the government lunged in to cushion the blow. The Fed could have easily injected Bear with cash and essentially nationalized the firm, as it later was to do with AIG AIG. But the decision was ultimately made to pursue a partnership with the private sector. It was part perception (fear of moral hazard) and part risk sharing (the Fed didn’t want to go it alone).

Dimon worked out a deal that shocked all of Wall Street. JP Morgan agreed to acquire Bear for $2 a share or a measly $236 million. He also got the Fed to take $29 billion worth of Bear’s toxic assets off its balance sheet.

Bear’s shareholders balked at the agreement. After all, Bear was trading at $172 a share only a year ago and was at $30 a share the previous week. It is here where Mr. Dimon could have just walked away, allowing Bear to go bankrupt. But if he did, the company’s assets would have probably been divvied up amongst his competitors and he would have lost his chance of picking up all those assets on the cheap. No, this wasn’t a Fed favor — the deal simply was too good to pass up. So good that Dimon caved and paid five times the original price to get the deal done.

Yesterday, Dimon offered further insight on how the deal was structured. He said that instead of giving the government the worst of the worst securities that Bear owned, he actually gave them investment grade securities while JP Morgan JPM kept all the bad ones. Well, that isn’t entirely true. While the vast majority of what the Fed took over was investment grade when it came into their possession, it wouldn’t stay that way for very long. In fact, the day after the agreement was signed, several assets fell into junk territory. We would come to learn in subsequent reports from the Fed that a little over half of the residential mortgages that were diced up in the securities the Fed had received in the deal were located in California and Florida — two of the hardest-hit regions of the housing bubble. By March of 2010, the Fed’s portfolio of Bear assets had decreased by almost $4 billion due to mark-to-market write downs.

In March of 2009, JP Morgan released its 2008 annual report in which investors could finally see the impact Bear was having on the firm. The biggest ramification was in asset management where JP Morgan picked up a ton of “good” interest-earning assets. The addition of those assets, combined with wider spreads in the market during that time, saw the firm’s total net interest income jump from $4 billion in 2007 to a whopping $10.3 billion in 2008. The report attributed a large part of the increase directly to Bear Stearns’ Prime Services business, meaning that Bear wasn’t just a bunch of toxic assets — it actually had earnings potential. The firm also attributed $237 million in revenue from its Private Wealth Management Arm due to the addition of hundreds of new clients from Bear Stearns’ Brokerage arm. Lastly, the firm took possession of Bear’s relatively brand-new 45-story headquarters in mid-town Manhattan, which was worth at the time around $300 million.

JP Morgan noted that the merger with Bear had “no material impact on the Firm’s liquidity,” so all those “toxic,” apparently weren’t such a big problem, thanks in part due to the $28.85 billion it received from the Fed. That made it easy to swallow the $10 billion in asset write-downs that the firm took across all of its business lines. Despite all the write-downs and losses, JP Morgan estimated that Bear would ultimately contribute $1 billion to the firm’s net income in 2009.

It’s now hard to tell where JP Morgan starts and where Bear Stearns ends as the two firms have been fully integrated – at least when it comes to their financials. But where you do see Bear’s name in recent filings is in the dreaded litigation section as pretty much anyone who ever lost money in any way shape or form with Bear has a lawsuit pending. JP Morgan doesn’t break out how much it has set aside to fight and settle its legal woes, but Bank of America BAC estimates it to be somewhere in the range of $13 billion.

JP Morgan is liable for any malfeasance committed by Bear, so it will be wrapped up in litigation for some time. The firm has settled a few big cases this year, notably with the employees of Bear Stearns who alleged that former Bear management defrauded them into thinking the firm was solvent when it was really on the edge. Many Bear employees lost the vast majority of their savings when the company’s stock price collapsed. In the end, JP Morgan agreed to pay $275 million to settle that claim — a fraction of the $18 billion in market value that Bear lost in its last year.

While JP Morgan has settled that highly public claim, it is also facing big lawsuits from the likes of Bank of America ($535 million), A Cayman feeder fund ($700 million), and Germany’s DZ Bank ($402 million). But potential biggie is a slew of individual and class-action lawsuits surrounding the sale of mortgage-backed securities by Bear that were worth $130 billion. This pile will probably grow as the New York Attorney General’s claim, filed last week, gets added to the heap. It is unclear if JP Morgan will have to pay a cent here, but it could be liable for some massive fine, which is possibly where Mr. Dimon is getting that $5 billion-$10 billion.

But what about all that toxic sludge Bear brought over? Is that still a problem? Ironically, it may not be. The Fed was able to sell all of the supposedly toxic stuff it took from Bear’s balance sheet at face value, much of it earlier this year to hedge funds and banks seeking higher yielding assets. So it could be the case that JP Morgan could continue to sell what it thought was toxic assets for more than they ever imagined. That would probably cover the rest of their lawsuits and yield the firm a nice profit. Combine that with the billions of dollars that Bear’s prime brokerage and private wealth management businesses have already generated for the firm, and this deal still looks pretty good. In other words, if Dimon wants to play the victim, he should stick with that whole whale thing and leave the Bear alone.

Correction: An earlier version of this story said that Jamie Dimon spoke in New York. In fact, the talk was at CFR’s offices in Washington.