NEW YORK — JPMorgan Chase has agreed to a $13-billion settlement with the government over selling shoddy mortgage investments, ending a legal battle that signals a tougher stance against Wall Street wrongdoing.

The nation's largest bank admitted to knowingly peddling the toxic securities that helped lead to the housing bubble and the worst financial meltdown since the Great Depression. The settlement is the largest made by any single American company in history.

California, slammed by 1 million foreclosures during the mortgage meltdown, will be a major beneficiary of the deal.

The agreement includes $4 billion to help homeowners in the Golden State and across the nation who were foreclosed on or who are struggling with their loans. California pension funds, which were big investors in mortgage securities, will receive nearly $300 million in damages to cover losses to the retirement accounts of state employees and teachers.

For the Justice Department, it was a much-needed win. Critics have lambasted the government for not doing enough to hold banks accountable for financial chicanery that helped trigger a global recession.

“Before the crisis, Big Brother was asleep on the couch,” said Mike Mayo, a banking analyst at CLSA in New York. “Now Big Brother is coming back with a vengeance.”

JPMorgan has long contended that the government's case against it was unfair because many of the problem mortgage securities came from investment bank Bear Stearns Cos. and thrift Washington Mutual. JPMorgan purchased those crippled institutions at the depths of the financial crisis at the urging of the federal government.

Jamie Dimon, JPMorgan's chairman and chief executive, said the bank was “pleased to have concluded this extensive agreement” that covers a “very significant portion” of its legacy mortgage problems.

Legal experts expect U.S. prosecutors to use JPMorgan's $13-billion deal as a template to extract significant sums from other major banks accused of wrongdoing.

The settlement did not single out any JPMorgan employees for illegal activity. However, the government is continuing a criminal probe led by Benjamin Wagner, the U.S. attorney in Sacramento. His jurisdiction includes California's Central Valley, one of the areas hit hardest by foreclosures and defaults.

Wagner's investigation was instrumental in the government's case against JPMorgan. Many of California's troubled subprime loans were originated by Washington Mutual and a lending unit of Bear Stearns.

“We saw in a very graphic way the effects of the financial crisis,” Wagner told reporters in Sacramento. “It certainly had a very negative impact in this region and damaged a lot of people in a very profound way.”

He said the criminal investigation of JPMorgan and its employees is “active and ongoing.” But, he said, it was too soon to know where it would lead.

The $13-billion settlement is by far the biggest amount ever paid by a Wall Street bank to settle civil charges, and eclipses the
$4 billion paid by oil giant BP after the 2010 Gulf of Mexico oil spill. It is equivalent to more than half of JPMorgan's 2012 profit.

However, the banking giant did catch some breaks.

JPMorgan said during a conference call that $7 billion of the settlement would be tax deductible. That could save the company nearly $2.5 billion, based on the top U.S. corporate tax rate of 35%.

The $4 billion going to homeowner relief isn't a cash outlay for JPMorgan, rather principle forgiveness and other programs to help people underwater on their loans.

Only $2 billion of the total deal is considered a fine.

Dennis Kelleher, president of the investor advocacy group Better Markets Inc., said the settlement “may be a historic amount of money, but it may also be an indefensible sweetheart deal for the country's largest bank.”

He questioned why the settlement featured no civil cases against individuals, and prodded the government over what he said were too few disclosures about the deal's terms.

Justice Department officials nevertheless hoped the settlement's sheer magnitude would portray an emboldened federal government that will use big fines to deter Wall Street wrongdoing.

“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,” U.S. Atty. Gen. Eric Holder said in a statement. “The size and scope of this resolution should send a clear signal that the Justice Department's financial fraud investigations are far from over.”

There are still a number of investigations yet to be resolved that could hurt major Wall Street banks. These include newly discovered misdeeds in the rigging of key interest and currency exchange rates.

The Justice Department's tough stance already has some fretting over a possible new wave of regulatory assaults.

“The anxiety both at the senior executive level as well as board level is exceedingly high,” said Todd Hagerman, a banking analyst at Sterne Agee & Leach Inc. “They're getting hit from all directions, and just when they thought they put one issue to rest, something else comes up.”

In Washington, lawmakers applauded the settlement as a victory for taxpayers. Sen. Bernie Sanders (I-Vt.) said he was pleased officials were taking action.

“What the American people understand is that we continue to be in the midst of a terrible, terrible economic downturn because of the greed and recklessness and illegal behavior of Wall Street,” Sanders said. “And I think people want justice to be done.”

It was unclear Tuesday how the $4-billion relief program would be apportioned to struggling homeowners. JPMorgan said it would distribute the assistance over the next four years. Government officials said California would receive a large share.

Half of the program would go toward writing down the balance of mortgages and waiving certain payments on home loans. Most of that would be achieved through outright forgiveness of first-mortgage debt.

The remaining $2 billion is to be allocated for various other uses, including aid to help low-income people buy homes, reduction of the interest rate on mortgages and efforts to reduce blight in neighborhoods most affected by foreclosures.

California's public pension plans will also get some cash. The California Public Employees' Retirement System will receive $221.6 million, while the California State Teachers' Retirement System will receive $19.5 million. Smaller state-run pension plans will receive lesser amounts.

Investors in JPMorgan appeared to be relieved the bank was able to settle much of its hefty legal tab. The New York company's shares rose 41 cents, or 0.7%, to $56.15 on Tuesday, while major U.S. stock indexes edged lower.

CEO Dimon sounded upbeat on a conference call with analysts to discuss the settlement. He still insists most of JPMorgan's toxic mortgages were inherited from its crisis-era acquisitions.

“It was a house on fire — it was imploding,” Dimon said of Bear Stearns. “We did it because we were asked to. We never expected this kind of stuff to happen.”

andrew.tangel @latimes.com

marc.lifsher@latimes.com

scott.reckard@latimes.com

Times staff writers Jim Puzzanghera and Andrew Khouri contributed to this report.