In a long-awaited decision issued on Friday, New York Supreme Court Justice Barbara Kapnick largely approved a $8.5 billion settlement between Bank of America Corp and mortgage-backed securities investors, resolving in one fell swoop much of the bank’s liability for its acquisition of Countrywide Financial Corp. The decision is a victory for Bank of New York Mellon, the trustee for Countrywide MBS trusts, which threw its weight behind the settlement. It’s also a victory for Kathy Patrick of the boutique law firm Gibbs & Bruns, who negotiated the deal on behalf of 22 institutional investors and defended it during a contentious court proceeding.

The settlement resolves past and future claims that BofA, which acquired Countrywide in 2008, should repurchase home loans underlying more than $400 billion in MBS sold by Countrywide before the financial crisis. Some large MBS investors, including American International Group, argued that the settlement did not adequately compensate them for signing away their claims.