Wells Fargo officially finalized its agreement with the federal government to pay $1.2 billion, in what is now the largest recovery for loan origination violations in FHA’s history.

The settlement resolves claims related to Wells Fargo’s Federal Housing Administration mortgage insurance lending program for the time period between 2001-2010.

According to a press release from the Department of Justice, Wells Fargo admitted, acknowledged and accepted responsibility for, among other things, certifying to the Department of Housing and Urban Development, during the period from May 2001 through December 2008, that certain residential home mortgage loans were eligible for FHA insurance when in fact they were not, resulting in the Government having to pay FHA insurance claims when some of those loans defaulted.

Wells Fargo originally tried to dismiss the series of statutory claims filed by the U.S. government back in October 2012 but was denied by a judge.

The claims accuse Wells Fargo of misleading HUD into believing its loans qualified for insurance from HUD's FHA. The government sought damages and civil penalties under the False Claims Act.

The settlement hit a roadblock back in November 2014 when both sides’ talks of negotiating a settlement started to slow down, with both parties no longer as optimistic as they once were.

While the details of the settlement were brought to light in a filing with the Securities and Exchange Commission earlier this year, there was no assurance that the two parties would agree on the final documentation of the settlement.

When those details came out, Wells Fargo said in a 10-K filing with the SEC that the bank was also under investigation by a number of agencies over the mortgage operations of both Wells Fargo and its “predecessor institutions.”

The final agreement with the government on Friday addressed this stating:

The agreement resolves the United States’ civil claims in its lawsuit in the Southern District of New York, as well as an investigation conducted by the U.S. Attorney’s Office for the Southern District of New York regarding Wells Fargo’s FHA origination and underwriting practices subsequent to the claims in its lawsuit and an investigation conducted by the U.S. Attorney’s Office for the Northern District of California into whether American Mortgage Network (AMNET), a mortgage lender acquired by Wells Fargo in 2009, falsely certified and submitted ineligible residential mortgage loans for FHA insurance.

Now nearly four years later, U.S. District Judge Jesse Furman for the Southern District of New York finally approved a settlement late Friday afternoon.

“Today’s court filing details a previously announced agreement in principle that resolves not only the pending lawsuit filed by the U.S. Attorney for the Southern District of New York, but also a number of other potential claims going back as far as 15 years in some cases,” said Franklin Codel, president of Wells Fargo Home Lending. “It allows us to put the legal process behind us, and to focus our resources and energy on what we do best—serving the needs of the nation’s homeowners.”

“We are dedicated to providing access to credit to a broad range of customers through offerings that exist today as well as new products and programs on the horizon,” added Codel. “Wells Fargo has helped millions of people buy homes and we will continue to meet the financing needs of the customers and communities the FHA program is intended to serve.”

“This Administration remains committed to holding lenders accountable for their lending practices,” said Secretary Julián Castro for HUD. “The $1.2 billion settlement with Wells Fargo is the largest recovery for loan origination violations in FHA’s history. Yet, this monetary figure can never truly make up for the countless families that lost homes as a result of poor lending practices.”