Bank of America Corp.’s Countrywide unit agreed to pay $500 million to settle a lawsuit over billions of dollars in residential mortgage-backed securities that were downgraded to junk.

The accord will end a class action led by the Iowa Public Retirement System, lead plaintiffs’ attorney Steven Toll of Cohen Milstein Sellers & Toll PLLC said today in a statement. The settlement, which couldn’t immediately be verified in court records, requires a judge’s approval, Bank of America said in a filing with the U.S. Securities and Exchange Commission.

“This settlement will bring closure to investors who were misled about the quality of the mortgages that Countrywide securitized,” Toll said.

The consolidated lawsuit filed in 2010 sought damages over $351 billion in downgraded Countrywide mortgage-backed securities after the 2007 subprime collapse. U.S. District Judge Mariana Pfaelzer in Los Angeles narrowed the case to $2.6 billion in bonds and dropped Charlotte, North Carolina- based Bank of America as a defendant.

The Los Angeles lawsuit was, at $351 billion, the largest in terms of securities at stake among dozens of cases brought against lenders and underwriters.

The case isn’t part of an $8.5 billion settlement between Bank of America and 22 institutional investors in Countrywide mortgage-backed securities. Investors’ rights to receive trust distributions upon final approval of that accord won’t be affected by the Los Angeles settlement, Bank of America said.

The Los Angeles case is Maine State Retirement System v. Countrywide Financial Corp., 10-cv-00302, U.S. District Court, Central District of California (Los Angeles).