In addition, Bank of America has agreed to buy back 30,000 mortgages for $6.75 billion, and pay a further $1.3 billion in compensation.
Fannie Mae argued the bank sold it toxic debts and should be responsible for the losses it suffered as result.
Separately, ten big mortgage providers agreed to pay $8.5 billion in compensation for mistakes in repossessing homes.
The banks include Bank of America, Citigroup, JP Morgan and Wells Fargo. They will pay $3.3 billion 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.2 billion.
Fannie Mae supports the US mortgage market, which collapsed in 2008 after the housing bubble burst.
In the run-up to the financial crisis of 2007-8, 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 $30 billion, 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 $140 billion to keep the firms afloat.
Bank of America settled with Freddie Mac in 2011.
The agreement brings to an end a long-running dispute between Fannie Mae and Bank of America.
“A favorable 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.4 trillion, with outstanding balances of $300 billion.
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 $20 billion 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.
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…