The Federal Housing Finance Agency, which regulates Fannie Mae and Freddie Mac, said Friday that it struck a separate $5.1 billion deal with JPMorgan Chase over faulty mortgage practices, rather than wait for the Justice Department to finalize its share of a tentative $13 billion deal with the bank.

Until now, the FHFA had agreed to bundle its lawsuit against the bank into a global settlement that federal prosecutors have been working on for months. The back and forth proved too much for the housing regulator, which decided to take matters into its own hands, said a person familiar with the deal who was not authorized to speak publicly.

The FHFA sued JPMorgan, along with 17 other financial firms, on behalf of government-controlled Fannie Mae and Freddie Mac two years ago. The regulator accused the firms of misleading the mortgage-finance twins about the quality of the mortgages pooled into securities. When those mortgages soured, the securities were worthless and saddled Fannie Mae and Freddie Mac with billions in losses.

Friday’s deal calls for JPMorgan, the nation’s largest bank, to pay about $2.7 billion to Freddie Mac and $1.3 billion to Fannie Mae to resolve claims related to mortgage securities sold to the companies between 2005 and 2007 by the bank and two firms it acquired, Bear Stearns and Washington Mutual.

That $4 billion deal will be carved out of the larger $13 billion deal being finalized by the Justice Department.

In a separate deal, JPMorgan also agreed to pay more than $1 billion directly to Fannie Mae and Freddie to resolve disputes over mortgages that the financing giants insured that went bad. Fannie Mae will receive $670 million as part of this deal, while Freddie Mac will get $480 million.

JPMorgan is one of many lenders that sell home loans to Fannie Mae and its sister agency, Freddie Mac, which bundle them into mortgage-backed securities and cover the losses if a homeowner defaults. The mortgage-finance companies suffered massive losses during the housing crash, requiring a $188 billion taxpayer bailout.

Fannie Mae and Freddie Mac have combed through millions of loans looking for shoddy underwriting to force mortgage lenders to buy them back.

“One of our goals in 2013 was to put legacy issues behind us so we can focus on building a stronger housing finance system for the future,” Timothy J. Mayopoulos, president and chief executive of Fannie Mae, said in a statement.

In a statement, JPMorgan said the deal is “an important step towards a broader resolution” with Justice and the other government authorities.

The $4 billion agreement marks the fourth lawsuit that the FHFA has resolved on faulty mortgages, with Citigroup, General Electric and UBS reaching settlements this year. Reuters reported this week that the housing agency was near a deal with Bank of America for a $6 billion agreement. Officials at Bank of America and the FHFA declined to comment on those negotiations.

The FHFA’s acting director, Edward DeMarco, said the deal “provides greater certainty in the marketplace and is in line with our responsibility for preserving and conserving Fannie Mae’s and Freddie Mac’s assets on behalf of taxpayers.”

The FHFA agreement puts to rest part of a long-standing dispute between JPMorgan Chase and the Federal Deposit Insurance Corp. The banking regulator and JPMorgan have for the past five years been fighting over who is responsible for losses on failed mortgages issued by Washington Mutual, the failed bank that JPMorgan bought out of receivership for $1.9 billion.

Some of those securities were at the heart of the FHFA’s lawsuit against JPMorgan. Friday’s agreement prevents the bank from pushing those liabilities onto the FDIC, which otherwise could have been forced to absorb billions of dollars in losses.

Although the FHFA stepped out on its own with the settlement, New York Attorney General Eric Schneiderman, co-chair of a group of state and federal authorities involved in the larger Justice settlement talks, applauded the deal.

“Five years after the financial crisis, it is critical that we continue to share resources to maximize the relief provided to struggling homeowners and ensure accountability for those who created the crisis in the first place,” said Schneiderman’s spokesman, Damien LaVera.

It is still unclear when the larger settlement will be completed. About $4 billion of that settlement is earmarked for consumer relief, while the rest is to be divvied up between state and federal authorities.

Even at the lower price tag, $9 billion, the deal is expected to exceed the Justice Department’s largest single company settlement on record — a $3 billion deal with Glaxo­SmithKline in 2011.

JPMorgan has urgently been attempting to settle investigations involving its actions during the financial crisis and since then. But the bank’s reluctance to admit wrongdoing has been a sticking point in finalizing the deal, a law enforcement official familiar with the negotiations has said.

The Justice Department, which refused to grant JPMorgan a waiver from criminal prosecution as part of a deal, plans to use its settlement with the bank as a blueprint for reaching similar deals with others in probes related to bad mortgages and the 2008 financial crisis, the person said.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.

To pause and restart automatic updates, click "Live" or "Paused". If paused, you'll be notified of the number of additional comments that have come in.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.