The city Board of Elections has settled a lawsuit over its illegal purging of over 200,000 voter registrations prior to the 2016 primary elections, the New York attorney general said Wednesday.

The good government group Common Cause New York sued the BOE in November 2016 after hundreds of voters, including many in Brooklyn, arrived at the polls on April 19, 2016, and were told they were no longer registered. Attorney General Eric Schneiderman’s office and the Justice Department later joined the lawsuit.

The registrations, including 117,000 in Brooklyn, had been purged by the BOE for illegal reasons such as canceling a registration because an individual had not voted in the past or deregistering people based on a change of address without giving them the proper time to confirm their addresses, Schneiderman said.

In the settlement, the BOE admitted that the removal of the plaintiffs’ names violated state and federal law, according to the Lawyers’ Committee for Civil Rights Under Law, which filed the lawsuit, in partnership with Latino Justice PRLDEF and Dechert LLP, on behalf of Common Cause New York.

The BOE also agreed to reinstate all voters that were improperly purged from the rolls and will create new policies that would prevent a similar mass removal of registrations from happening in the future, the organization said.

“[The] settlement represents an important victory for the future of New York City elections. New Yorkers deserve a system that lives up to their appropriately high expectations, and Common Cause New York is here to make sure that’s what they get,” said Susan Lerner, executive director of Common Cause New York. “Voting should be an easily accessible right instead of subject to unnecessary obstacles.”

The deal still needs to be approved by a court judge.

A spokeswoman for the Board of Elections said the agency would not comment on the settlement until a judge approves it.