By Aruna Viswanatha, Emily Flitter and David Henry

NEW YORK (Reuters) - JPMorgan Chase & Co <JPM.N> is in last-minute talks with the U.S. government to settle a civil case that was to be filed accusing the bank of violating U.S. laws in its sale of mortgage bonds in California, according to sources familiar with the matter.

The case, which was to be filed on Tuesday by the Justice Department in the Eastern District of California, deals with the bank's sale of bonds backed by subprime mortgages and other risky home loans between 2005 and 2007.

It was not clear what led to restarting the settlement talks. Sources said talks had broken down over the amount the bank would pay in a penalty. There was no immediate indication of how much JPMorgan would have to pay in fines to settle the civil case.

The New York Times reported on Monday that the Department of Housing and Urban Development had suggested a broader settlement of $20 billion (12.5 billion pounds), but the housing agency on Tuesday said that was "categorically false."

"The department takes the allegations against JPMorgan Chase seriously and has been involved in multi-party negotiations to reach a settlement. However, no one at this agency - including the secretary - ever floated a $20 billion settlement figure," HUD general counsel Helen Kanovsky said.

Experts said the new move toward settlement talks appeared to be driven by a strong desire within the bank to move past its legal troubles as quickly as possible, but that the Justice Department likely has the upper hand in the talks, given how close it came to filing the suit.

In a regulatory filing in August, JPMorgan disclosed it was under parallel civil and criminal investigations by federal authorities in California and that authorities on the civil side had told the bank in May they had preliminarily concluded it violated federal securities laws.

A spokesman for the bank, Brian Marchiony, declined to comment.

To observers, another legal battle was the last thing the largest U.S. bank needs as it struggles to move past conflicts with regulators and prosecutors involving several business lines.

"The way I see this, JPMorgan would like to avoid the continuing Chinese water torture of reputational damage they've been suffering," said Kathleen Wailes, senior vice president at LEVICK, a public relations and crisis-management firm in Washington.

"They would like to dispose of this in a settlement as opposed to a trial and get rid of this as quickly as they can to move on the more positive subjects," Wailes said.

On Thursday, JPMorgan agreed to pay $1 billion to settle regulatory actions related both to a $6.2 billion trading loss it incurred last year in its Chief Investment Office and allegations of wrongful billing of credit-card customers.

Last week's settlements were part of a new push by the bank to try to remake its public image into one displaying more deference toward regulators.

"The government is attacking very weak prey now," said Jonathan Macey, a corporate law professor at Yale Law School.

"I certainly don't think we can say JPMorgan is in a strong position because they've experienced such a relentless onslaught of legal and regulatory actions," Macey said.

JPMorgan is, however, financially strong and making record profits, despite the damage to its reputation, the payment of about $5 billion in legal costs annually, and the constraint of government orders to fix its risk controls and legal compliance systems.

The company reported net income of $21.3 billion last year and analysts expect profits this year to be even higher.

JPMorgan's stock price on Tuesday afternoon was about 25 percent higher than before it disclosed in May 2012 that it was losing billions of dollars on its Chief Investment Offices' "London Whale" derivatives trade.

CEO Jamie Dimon said in a statement issued by the company on Thursday, "We have accepted responsibility and acknowledged our mistakes from the start, and we have learned from them and worked to fix them."

(Reporting By Aruna Viswanatha in Washington and Emily Flitter and David Henry in New York; Editing by Gerald E. McCormick, Nick Zieminski and Leslie Adler)