Finally, judge approves $8.5B BofA mortgage bond settlement.

The decision is likely to resolve one of the second-largest U.S. bank's last and largest legal liabilities related to the financial crisis.

A New York state appeals court has approved Bank of America’s $8.5 billion deal with investors over bad mortgages, potentially putting to rest a legal dispute that dates to 2011.

The decision is likely to resolve one of the second-largest U.S. bank's last and largest legal liabilities related to the financial crisis.

Thursday's ruling by the appeals court reversed a decision made by a New York State Supreme Court judge in January 2014, which concluded that Bank of America did not have to repurchase the faulty loans because the trustee, Bank of New York-Mellon, did not evaluate them properly.

Bank of America had agreed to the 2011 settlement with 22 bondholder groups including Blackrock Inc. and Pacific Investment Management Co. The deal was over claims that the lender’s Countrywide unit bungled servicing and didn’t repurchase shoddy mortgages.

Bank of America's January 2008 acquisition of the then-biggest residential mortgage lender in the nation, Countrywide Home Loans, for $4.1 billion has since cost the megabank at least $60 billion in settlements and legal expenses, including a record $16.65 billion settlement with the Department of Justice in August 2014 over the sales of faulty securities leading up to the financial crisis.