JPMorgan has several lawsuits pending against it and the mortgage businesses it bought from Bear Stearns and Washington Mutual in 2008. There's also an ongoing criminal investigation led by the office of U.S. Attorney Benjamin Wagner in Sacramento, Calif.
The bank may be negotiating or litigating for years and has set aside $23 billion to cover those costs. Last month, in a filing with the Securities and Exchange Commission, it said it may need up to $5.7 billion more.
In a conference call with investors Tuesday, JPMorgan's chief financial officer, Marianne Lake, said it was "too early" to discuss whether the bank would have to add to its legal reserves.
"These things are never 'one and done,' and they'll likely be more civil charges," said Erik Oja, an equity analyst with Standard & Poor's who covers the U.S. banking industry. But, Oja added, "these sort of settlements really do help clear away most of the issues."
The deal also included settlements with New York, California and other states. It was reached after months of negotiations and could serve as a template for similar settlements with other big banks.
As part of the deal, JPMorgan agreed to provide $4 billion in relief to homeowners affected by the bad loans. The bank also acknowledged that it misrepresented the quality of its securities to investors.
JPMorgan was among the major banks that sold securities that plunged in value when the housing market collapsed in 2006 and 2007. Those losses triggered a financial crisis that pushed the economy into the worst recession since the 1930s.
"The conduct uncovered in this investigation helped sow the seeds of the mortgage meltdown," Attorney General Eric Holder said. "JPMorgan was not the only financial institution during this period to knowingly bundle toxic loans and sell them to unsuspecting investors, but that is no excuse for the firm's behavior."
JPMorgan will pay $2 billion in civil penalties to the federal government and about $1 billion to New York state. An additional $6 billion will go toward compensating investors.
In a statement, JPMorgan CEO Jamie Dimon said the settlement covers a "very significant portion" of the banks troubled mortgage-backed securities, as well as those it inherited when it purchased Bear Stearns and Washington Mutual in 2008.
"We are pleased to have concluded this extensive agreement with the (government) and to have resolved the civil claims of the Department of Justice and others," Dimon said in the statement.
The deal eclipses the record $4 billion levied on oil giant BP in January over the 2010 offshore oil spill, which was the worst in U.S. history.
While the $13 billion that JPMorgan is paying is a staggering sum, it represents only about 60 percent of the bank's $21.3 billion net income reported for 2012.
According to the Justice Department's statement of facts agreed to by JPMorgan, many of the mortgage loans were referred to inside JPMorgan as "rejects." Those loans were missing appraisals or proof of borrower's income, employment or assets.
In one review, consultants hired by the bank found that more than a quarter of loans in a pool of tens of thousands were "rejects." Yet JPMorgan ultimately accepted half of those rejects and re-graded them as acceptable.
Wagner, the U.S. attorney in Sacramento, said at a news conference that the activity described in the settlement was "symptomatic of the recklessness on Wall Street."
Asked about a timeframe for resolving the criminal probe, Wagner said, "You'll just have to stay tuned. We're going to keep plugging away."
New York Attorney General Eric Schneiderman said at a news conference that there isn't any specific relief in the settlement for people who have already lost their homes to foreclosure.
And Scheiderman said that JPMorgan could deduct from its income taxes most of the $13 billion it is paying. But the exact amount isn't clear.
"There's going to be issues with the IRS," he said.
Of the $4 billion set aside for consumer relief, about a third will be used to write down mortgage principal. Dennis Kelleher, the president of Better Markets, a group that advocates strict financial regulation, said JPMorgan may receive credit for loans that it previously wrote down.
"Banks agree to do things that they are doing already, and then they get credit for it," Kelleher said. "It's not $4 billion in actual dollars. Its $4 billion in value that JPMorgan claims it is paying."
The bank will use some of the money to reduce mortgage rates, issue new loans and help revive blighted properties in cities hit hard by the housing crisis.
An independent monitor will be appointed to oversee the assistance to homeowners.
As part of the $6 billion to investors, $4 billion will resolve government claims that JPMorgan misled mortgage finance giants Fannie Mae and Freddie Mac about risky mortgage securities the bank sold them before the housing market crashed. That part of the deal was announced Oct. 25. Fannie and Freddie were bailed out by the government during the crisis and are under federal control.
Mounting legal costs from government proceedings pushed JPMorgan to a rare loss in this year's third quarter, the first under Dimon's leadership.
On Friday, the company announced it had reached a $4.5 billion settlement with 21 major institutional investors over mortgage-backed securities issued by JPMorgan and Bear Stearns between 2005 and 2008. The investors, which include Goldman Sachs, said the bank deceived them about the quality of high-risk mortgage securities.
Sweet reported from New York. Associated Press writer Don Thompson in Sacramento, Calif., contributed to this report.
Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.