The settlement announced Tuesday with the Department of Justice is the largest ever between the U.S. government and a corporation. It also included settlements with New York, California and other states.
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 deal 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.
"Without a doubt, 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 behaviour."
JPMorgan will pay $2 billion in civil penalties to the federal government and about $1 billion to New York state. Another $6 billion will go toward compensating investors.
In a statement, JPMorgan CEO Jamie Dimon said that the settlement covers a "very significant portion" of the bank's 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 per cent of the bank's $21.3 billion net income reported for 2012. And JPMorgan has already set aside $23 billion this year to cover the settlement and other costs related to its legal troubles.
JPMorgan could still face criminal charges. An investigation is under way by the office of U.S. Attorney Benjamin Wagner in Sacramento, Calif., focused primarily on JPMorgan employees.
Wagner told a news conference Tuesday 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."
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.
The settlement should clear away nearly all of JPMorgan's legacy legal troubles that the bank inherited when it purchased Washington Mutual and Bear Stearns, said Erik Oja, an equity analyst with Standard & Poor's who covers the banking industry.
"These things are never 'one and done' and there'll be more civil charges, but as we have seen in the past, these sort of settlements really do help clear away most of the issues a bank might have had in the past," said Oja, who has a "strong buy" on JPMorgan's shares.
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 also 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.
AP Business Writer Ken Sweet in New York and Associated Press writer Don Thompson in Sacramento, Calif., contributed to this report.