Image caption The bank is also the subject of a civil lawsuit brought by federal prosecutors

Bank of America has agreed to pay US government mortgage agency Fannie Mae $11.6bn (£7.2bn) to settle claims relating to residential home loans.

The bank will pay $10.3bn to settle claims relating to the loans and $1.3bn in compensation to the agency.

Fannie Mae argued the bank sold it toxic debts and should be responsible for the losses it suffered.

Separately, 10 big mortgage providers agreed to pay $8.5bn compensation for mistakes in repossessing homes.

The banks include Bank of America, Citigroup, JP Morgan and Wells Fargo. They will pay $3.3bn directly to homeowners, some of whom should not have lost their homes, regulators said.

Individual owners will receive anything from a few hundred dollars to $125,000.

Loan assistance and write-offs will make up the remaining $5.2bn.

Heavy losses

Fannie Mae supports the US mortgage market, which collapsed in 2008 after the housing bubble burst. It buys mortgages from banks, providing them with more funds to lend out.

The agency said as part of the agreement Bank of America would make a cash payment of $3.55bn and in addition would repurchase about 30,000 loans for $6.75bn.

In the run-up to the financial crisis of 2007-08, home loans grouped together and sold on as investments became increasingly popular.

When the underlying mortgage holders were unable to repay their debts, the investments plummeted in value, with disastrous consequences for banks all over the world.

Freddie Mac is the other government mortgage agency. The two firms lost more than $30bn, partly because of their investments in the subprime mortgages, and were bailed out by the US government.

Since the rescues, US taxpayers have spent more than $140bn to keep the firms afloat.

Bank of America settled with Freddie Mac in 2011.

Bill Brown from Duke University, law professor and expert in financial services, told the BBC's World Service that this latest settlement with Fannie Mae was drawing a line under the whole subprime mortgage-backed securities saga.

"About a year or two ago there were many people worried that this line would not even start to be drawn. Right now we're 90% of the way to finishing the line."

'Significant step'

The agreement brings to an end a long-running dispute between Fannie Mae and Bank of America.

"A favourable resolution of this long-standing dispute between Fannie Mae and Bank of America is in the best interest of taxpayers," said Bradley Lerman at Fannie Mae.

The company said the loans "did not meet our standards at the time of origination, and we are pleased to have reached an appropriate agreement to collect on these repurchase requests".

The agreement covers loans worth about $1.4tn, with outstanding balances of $300bn.

Bank of America said the settlements were "a significant step in resolving our remaining legacy mortgage issues".

In October, the US government sued the bank for alleged mortgage fraud, accusing subsidiary Countrywide Financial of selling thousands of toxic home loans to Fannie Mae and Freddie Mac.

Earlier in the month, it took similar action against the banks Wells Fargo and JP Morgan Chase.

In October, JP Morgan was sued for allegedly defrauding investors who lost more than $20bn on mortgage-backed securities sold by Bear Stearns.

JP Morgan, which bought the investment bank in March 2008, said the allegations related to actions at Bear Stearns prior to its takeover.

In the same month, Wells Fargo was also sued by federal authorities for alleged mortgage fraud.