America’s second largest lender has reached a $16.65 billion settlement with US federal authorities for selling toxic mortgages misleading investors, the Justice Department said Thursday.

“This historic resolution - the largest such settlement on record - goes far beyond ‘the cost of doing business,’” Attorney General Eric Holder said in a statement posted on the US Justice Department website on Thursday.

The bank will pay out $9.65 billion in cash and $7 billion for consumer relief – such as modified home loans and refinanced mortgages.

"Under the terms of this settlement, the bank has agreed to pay $7 billion in relief to struggling homeowners, borrowers, and communities affected by the bank’s conduct. This is appropriate given the size and scope of the wrongdoing at issue,” the statement says.

The bank has agreed to pay a $5 billion 'civil penalty' to settle claims under the Financial Institutions Reform and Recovery Enforcement Act (FIRREA), a federal law introduced after the loan crisis in the 1980s.

To date, President Obama's Financial Fraud Enforcement Task Force and its Residential Mortgage-Backed Securities (RMBS) Working Group, have collected $36.65 billion from banks to redistribute to consumers and investors misled by the country's leading financial institutions.

The fine is the largest single compensation settlement, beating out JPMorgan Chase & Co’s $13 billion penalty paid in November 2013. Citigroup, another major US bank, had to pay $7 billion in July.

In March, the bank was ordered to pay $9.5 billion to the Federal Housing Finance Agency to resolve similar misconduct allegations. Since the financial crisis, the bank has been ordered to pay over $60 billion in fines, claims, and buying out mortgage bonds.

The bank admitted it misled investors about the quality of mortgage loan sale prior to the housing crash, when banks lent out too much money to homeowners who eventually could not pay off their loans.

This eventually resulted in the collapse of the housing bubble and the beginning of the recession in late 2007. The banks defrauded investors about the condition of the loans, which led to billions in losses while millions of Americans lost their homes to foreclosure.

Three quarters of the loans in question came from Countrywide Financial, which Bank of America acquired in 2009, along with Merrill Lynch. In total, between 2004 and 2008, the groups sold more than $965 billion in bad loans.

“In the run-up to the financial crisis, Merrill Lynch bought more and more mortgage loans, packaged them together, and sold them off in securities – even when the bank knew a substantial number of those loans were defective,” US Attorney Paul J. Fishman explained.