Royal Bank of Scotland will pay $5.5 billion to settle one of the two major U.S. investigations into allegations it mis-sold mortgage-backed bonds that it needs to resolve before the government can sell its shares in the bailed-out bank.

The Edinburgh-based bank lender on Wednesday said it agreed to settle the lawsuit with the U.S. Federal Housing Finance Agency (FHFA) that accuses it of mis-selling $32 billion of mortgage-backed securities before the global financial crisis.