The agreement is the latest chapter in the bursting of the housing bubble.
"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."
The settlement announced Tuesday requires JPMorgan to pay $9 billion and provide $4 billion in consumer relief, including principal reductions and other mortgage modifications for homeowners facing foreclosure.
According to a Justice Department document filed as part of the settlement, JPMorgan bundled low-quality loans, regraded them with better marks in order to make them more attractive and then sold them to investors without informing the buyers of the risk involved.
On Monday, the Justice Department's No. 2 official said too many financial institutions had failed in their duty to ensure that their businesses were run cleanly.
Recounting the conduct common to many banks including JPMorgan, Deputy Attorney General James Cole told the American Bankers Association that too many supervisors incentivized excessive risk taking, knowing that risky products "could be unloaded down the road, ... leaving someone else to deal with the consequences."
The final issue in the settlement revolved around the $4 billion to compensate consumers. Some $1.5 billion will be a write-down to reduce the principal of homeowner loans; $300 million will enable homeowners to pay less now on their mortgages; and the remainder of the $4 billion will go toward reducing mortgage interest rates, originating new loans and helping revive blighted properties in some of the hardest hit areas of the housing crisis, such as Detroit. An independent monitor will be appointed to oversee the assistance to homeowners.
The agreement eclipses the record $4 billion levied on oil giant BP in January over the worst offshore oil spill in U.S. history.
Still to come is a decision on whether the Justice Department will file criminal charges against JPMorgan. An investigation is under way by the U.S. attorney's office in Sacramento, California.
The nation's biggest bank will pay more than $6 billion to compensate investors, pay $4 billion to help struggling homeowners and pay the remainder as a fine.
JPMorgan has said most of its mortgage-backed securities came from Bear Stearns Cos. and Washington Mutual Inc., troubled companies that JPMorgan acquired in 2008.
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.
The $13 billion JPMorgan settlement amount is only about half of its record 2012 net income of $21.3 billion, or $5.20 a share, which made it one of the most profitable U.S. banks last year.
Mounting legal costs from government proceedings pushed JPMorgan to a rare loss in this year's third quarter, the first under CEO Jamie Dimon's leadership. The bank reported Oct. 11 that it set aside $9.2 billion in the July-September quarter to cover the string of legal cases against the bank. JPMorgan said it has placed $23 billion in reserve to cover potential legal costs.
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.