NEW YORK/WASHINGTON (Reuters) - In late September, JPMorgan Chief Executive Jamie Dimon walked into the office of U.S. Attorney General Eric Holder.

“We’re willing to take our lumps,” he said, according to a person briefed on the matter.

“We don’t think there were serious mistakes made,” he added, in a meeting he had requested with Holder.

JPMorgan finally took its punishment on Tuesday, agreeing to a $13 billion settlement with the U.S. government to settle charges that the bank overstated the quality of mortgages it was selling to investors in the run-up to the financial crisis.

The Department of Justice trumpeted its settlement as a big step toward holding banks accountable for their behavior before the financial crisis.

The behavior that the largest U.S. bank admitted to, authorities said, is at the heart of what inflated the housing bubble: lenders making bad mortgages and selling them to investors who thought they were relatively safe. When the loans started turning bad, investors lost faith in the banking system, and a housing crisis turned into a financial crisis.

The Justice Department said in its statement that JPMorgan acknowledged it had regularly and knowingly sold mortgages to investors that should have never been sold.

But JPMorgan’s Chief Financial Officer, speaking on a conference call, said the bank had not admitted to violating any laws. CFO Marianne Lake added that the facts the bank admitted to did not leave it vulnerable in other litigation.

In other words, the bank and the government did not agree about what they had agreed to in the settlement, capping weeks of squabbling over the terms of the deal.

At issue in Tuesday’s settlement was the long chain of companies between lenders giving mortgages to consumers during the mortgage bubble and the investors that ultimately forked over the money to fund the loans. Often smaller lenders would make subprime mortgage loans, and sell them to a bank, which would package loans into bonds, and in turn sell them to investors.

With so many middlemen, investors had poor information about what they were buying, and capital flowed to loans that arguably should never have been made.

A sign outside the headquarters of JP Morgan Chase & Co in New York, in this September 19, 2013 file photo. REUTERS/Mike Segar/Files

When the air hissed out of the U.S. mortgage market, investors said they were gulled, and that the mortgages they bought were not good enough in the first place to have been sold. Banks for their part have said that mortgages failed not because they failed to meet investors’ stated standards, but because the housing market as a whole headed south.

JPMorgan said it has set aside the funds it needs to cover the settlement, meaning the deal will have no impact on its future earnings. The deal resolves most of its mortgage issues with federal authorities, the bank said. JPMorgan’s shares rose 0.7 percent to close at $56.15 on Tuesday.

The civil settlement marks the end of weeks of tense negotiations between JPMorgan Chase, which is looking to move past the legal issues that have plagued it for more than a year, and the U.S. government, which is under pressure to hold banks accountable for behavior that led to the financial crisis.

But even after the settlement, the bank faces at least nine other government probes, covering everything from its hiring practices in China to whether it manipulated the Libor benchmark interest rate. It may still also face criminal charges linked to mortgage matters. Dimon avoided the worst pitfalls of the financial crisis, but now is discovering he did not avoid all of them.

BREAKING IT DOWN

The government called the settlement the largest in U.S. history, but the deal is really several rolled into one. It includes a $4 billion consumer relief package, and a $4 billion settlement with the Federal Housing Finance Agency, which oversees government mortgage financing companies Fannie Mae and Freddie Mac.

Of the $4 billion consumer relief package, at least $1.5 billion will go toward loans the bank is forgiving. As much as $500 million will go to change the terms of loans to lower monthly payments.

The remaining $2 billion will be for assorted purposes, including new loans for low- and moderate-income borrowers in areas that have been hard-hit by the housing crisis and for demolition of abandoned homes.

Of the $13 billion settlement, $4 billion is for the consumer relief package, $4 billion is for the FHFA deal, and $5 billion is for a civil penalty to the Justice Department and claims from other state and federal government entities.

After taxes, the settlement should cost JPMorgan about $9 billion, because about $11 billion of the settlement is tax deductible, said Gregg Polsky, a law professor at the University of North Carolina. The bank said last month it had set aside $23 billion to cover litigation expenses.

MORE COMING

JPMorgan admitted that it told investors the loans it was selling them met particular standards.

Outside firms that reviewed some of the loans for JPMorgan in 2006 and 2007 told bank employees that 27 percent of the mortgages did not meet underwriting guidelines. One employee expressed concerns about loans to another employee, the bank said in its statement of facts.

The bank and the Justice Department differed regarding how to interpret the statement of facts that the parties had agreed to.

A person involved in the JPMorgan negotiations said that the pattern of bad mortgages being packaged and sold to investors was spread throughout the banking industry. He noted that the bad deals in question were created not only by JPMorgan, but also by two failed banks it took over during the financial crisis, namely Bear Stearns and Washington Mutual.

“Right now, the banks all are holding their breath,” said James D. Cox, a law professor at Duke University who specializes in corporate and securities law. “They understand it means a big number for them as well.”

On a call with analysts, when asked why the Department of Justice acted first on JPMorgan, Dimon said: “You’ve got to ask them ... It could have been somebody else. There was going to be a first.”

JPMorgan and government agencies reached a tentative agreement in mid-October and have been hammering out details since then. New York Attorney General Eric Schneiderman was also involved in discussions.

JPMorgan’s negotiations with the Justice Department began in earnest last spring, after Justice Department lawyers in California preliminarily concluded that the bank had violated U.S. civil laws. The Justice Department had looked into mortgage bonds the bank sold from 2005 through 2007, the company said in August.

The talks went sour, and government lawyers prepared to file a lawsuit against JPMorgan in September and scheduled a news conference to announce it. But they canceled it at the last minute as JPMorgan reached out to government officials to discuss a settlement. That effort to restart talks resulted in JPMorgan’s Dimon meeting U.S. Attorney General Eric Holder.

Negotiations were difficult, people involved in the matter said. Parties joined the talks, then dropped out. In recent weeks, they stopped, only to restart. Details of the deal were being worked out hours before it was announced on Tuesday, said two people involved.

The bank’s general counsel, Stephen Cutler, and Associate Attorney General Tony West were critical in negotiating the deal, sources said. Cutler was previously director of enforcement at the Securities and Exchange Commission.

The settlement is the most significant action to come out of a task force the Obama administration created in January 2012, years after the height of the financial crisis, to probe the packaging and sale of shoddy home loans.

Lawmakers and others have been critical of the administration’s failure to hold Wall Street banks, executives, and other parties accountable for the excesses that resulted in the housing crisis.

The task force included representatives from the Justice Department, the U.S. Securities and Exchange Commission, and the New York State Attorney General, among others.

JPMorgan’s settlement was with the Department of Justice, several state Attorneys General, the Federal Deposit Insurance Corp, the National Credit Union Administration, and the FHFA.