JPMorgan Chase will pay $5.1 billion to settle allegations it misled mortgage-finance agencies Fannie Mae and Freddie Mac about the quality of residential mortgages the banking giant sold them during the national real estate boom, the Federal Housing Finance Agency announced Friday.

A total of $4 billion will resolve allegations that the nation's largest bank violated federal and state securities laws in connection with $33.8 billion in mortgages sold to the government-sponsored agencies by JPMorgan and its Bear Stearns and Washington Mutual units.

The New York-based bank separately agreed to pay approximately $1.1 billion to Fannie and Freddie to fund repurchase claims on single-family mortgages bought by the two agencies.

"This is a significant step as the government and JP Morgan Chase move to address outstanding mortgage-related issues," said FHFA Acting Director Edward DeMarco in a statement announcing the deals. He added that the combined settlements would "have a beneficial impact for taxpayers and the housing finance market."

The agreements resolve 2011 federal court lawsuits filed against JPMorgan by FHFA, which has served as the conservator of Fannie and Freddie since 2008.

The settlement marked the first step in what's expected to be a record-setting $13 billion package as JPMorgan bank tries to close the books on several government probes of mortgage-related actions by the bank itself and its Bear Stearns and Washington Mutual units.

Under the framework of a deal reached this month by Attorney General Eric Holder and JPMorgan CEO Jamie Dimon, the bank is expected to pay an additional roughly $2 billion in fines, $4 billion in consumer relief and $3 billion for investors who bought mortgage-backed securities that turned sour. That part of the agreement has not yet been officially concluded.

JPMorgan said Friday's settlements "are an important step towards a broader resolution of the firm's (mortgage-backed securities) related matters with governmental entities, and reflect significant efforts by the Department of Justice and other federal and state governmental agencies."

Friday's settlement and the pending agreement would add to the billions JPMorgan has already paid in recent government settlements. Within the last month alone, the bank admitted wrongdoing and agreed to pay more than $1 billion in settlements with five regulatory agencies for its now-notorious "London whale" trading debacle.

That case focused on an early 2012 episode involving London-based JPMorgan brokers who amassed large and risky investment positions in an effort to avoid massive loses in a credit portfolio. The bank violated federal securities laws by failing to keep watch over the traders' activities and withholding key information from regulators. The trading ultimately resulted in an estimated $6.2 billion in losses.

JPMorgan has also paid billions of dollars in other settlements in recent years, including $1.2 billion in August 2012 as its share of a class-action lawsuit that alleged it was one of several banks that conspired to set the price of credit card and debit card interchange fees.