This article, originally published at 6:54 p.m. on Friday, Aug. 19, 2016, has been updated with legal records and market data.

JPMorgan Chase (JPM) - Get Report  will avoid liabilities of $6 billion or more in a settlement ending litigation with Deutsche Bank National Trust and the Federal Deposit Insurance Corp. over defective home loans from Washington Mutual, the failed bank that CEO Jamie Dimon purchased during the financial crisis.

The New York company will also receive $645 million in cash, in turn dropping its claims of more than $1 billion against Washington Mutual's receivership, according to a regulatory filing on Friday. The settlement, which still must be approved by the courts, brings to a close Deutsche's suit on behalf of more than 100 trusts holding mortgage-backed securities from WaMu as well as JPMorgan's claim in a separate suit that the FDIC failed to honor all of its financial obligations after the WaMu sale.

A key question in both cases was whether JPMorgan (which purchased WaMu after it was taken over by the FDIC) or the FDIC was liable for WaMu's contractual obligation to buy back hundreds of faulty mortgage-backed securities that have since collapsed.

Spokespersons for the FDIC and Deutsche declined to comment. The federal agency agreed in the settlement to allow Deutsche a $3 billion claim against WaMu's estate, according to a person familiar with the case, a concession it had previously refused.

In earlier court filings, the FDIC argued that JPMorgan had assumed responsibility for the securities in its $1.9 billion acquisition. It appealed a June 2015 ruling by U.S. District Judge Rosemary Collyer that JPMorgan was only responsible for the repurchase obligations on the bank's books at the time of the Sept. 25, 2008 purchase.

The deal occurred during a particularly tense phase of the financial crisis, when the government was working to shore up the financial system after the failure of investment bank Lehman Brothers amid a severe downturn in the U.S. mortgage market.

Lehman's bankruptcy in mid-Setepmber 2008 had precipitated the second run on WaMu in less than a year. The bank lost almost $17 billion in deposits over an eight-day period, with average withdrawals topping $2 billion on several days, then-FDIC Chairwoman Sheila Bair told the Senate's permanent subcommittee on investigations in 2010.

Just two months earlier, the bank had lost $10 billion in deposits after the July failure of IndyMac, and on the day of its closure, cash on hand fell to $4.4 billion, a tiny fraction of WaMu's $300 billion in deposits.

Since the lenders weren't holding the loans they made on their own books, they were less concerned with borrowers' ability to repay, and home buyers often purchased residences beyond their means, believing that a continuous surge in the housing market would enable them to refinance before the higher rates on adjustable-rate mortgages kicked in.

"The embedded losses and liquidity problems had made the institution unviable," Bair said in 2010. "Critics may say it was overly harsh to close WaMu, but the reality is that mortgage losses were mounting, downgrades were occurring, and efforts to raise capital had been exhausted."

Home loans were at the heart of WaMu's troubles. In the years leading up to the crisis, the bank and other financial institutions had been packaging mortgages of widely varying quality into securities, which were then sold to Wall Street and other investors, enabling them to record profits immediately.

The mortgage market for one- to four-family homes widened 46% to a peak of $11.3 trillion in the four years through March 2008, according to Federal Reserve data. As the housing market contracted, though, buyers dried up and borrowers were stuck with loans they couldn't pay. Defaults surged and mortgage-backed securities became impossible to value, threatening many of the firms that owned them.

Further complicating matters, some securities issuers such as WaMu had contractual obligations to repurchase the securities if they failed to live up to the standards outlined at the time of sale. 

By purchasing WaMu, JPMorgan said in a December 2013 court filing, it "protected the FDIC from potentially unprecedented liability and helped ensure the stability of the country's banking system by enabling the former WaMu branches to remain open for business as usual."

Had the FDIC been forced to liquidate WaMu, it would have cost an estimated $41 billion, Bair estimated in her Senate testimony.

JPMorgan has climbed 62% to $65.63 since the WaMu purchase, trailing a gain of 84% by the S&P 500.