— A federal judge on Tuesday scrapped part of a North Carolina elections law that allowed people to challenge others' voter registrations.

U.S. District Judge Loretta Biggs ordered the State Board of Elections and Ethics Enforcement to ensure all 100 county boards of elections comply with provisions of the National Voter Registration Act, or NVRA, regarding removing people from voter rolls.

The ruling comes in a 2016 case in which elections officials in Cumberland, Moore and Beaufort counties canceled the registrations of thousands of voters in the weeks leading up to the November election.

State law has allowed any voter to challenge another voter's registration if they live in the same county. A challenge resulted in a hearing where the voter who was challenged could present evidence of his or her residence, and local elections officials then made the decision as to whether to remove the voter.

In 2016, one Cumberland County resident representing the Voter Integrity Project of NC challenged 4,000 voters, and a voter representing the Moore Voter Integrity Project challenged almost 500 Moore County voters. Four people in Beaufort County challenged about 140 voters there.

The challenges, made after a single piece of mail sent to voters by the activists went unreturned, were mostly upheld by the three county elections boards, and the registrations of about 3,900 voters were canceled.

Individuals whose registrations had been challenged and the state chapter of the NAACP sued, and days before the election, Biggs ordered the three counties to allow all of the voters who had been purged from the rolls to vote, calling the challenge process "insane."

"The odious practice of using mass mailings and undelivered mail to suppress and intimidate voters of color has a long and shameful history in North Carolina," Rev. T. Anthony Spearman, state president NAACP, said in a statement praising Biggs' decision in favor of the plaintiffs Tuesday.

In granting summary judgment, Biggs ruled that the three county boards didn't comply with NVRA standards for purging voters. The federal law requires that a voter not be purged unless he or she has provided written confirmation of a change of address or has failed to respond to a notice and didn't vote in two subsequent federal elections.

All three counties were dumping people from the voter rolls without waiting for the two election cycles to pass to see if the challenged voters had cast ballots, Biggs determined. She also found that the counties "systematically removed" voters from the rolls within 90 days of an election, which violates the NVRA.

"The NVRA encourages the participation of qualified voters in federal elections by mandating certain procedures designed to reduce the risk that a voter’s registration might be erroneously canceled. Defendants’ conduct contravened these procedures," she wrote in her 27-page ruling.

Jay Delancy, state director for the Voter Integrity Project, said the registration challenges were made to reduce the potential for voter fraud.

"We followed North Carolina law scrupulously," Delancy told The Associated Press, adding that his group would ask state legislators to revise the law "to empower private citizens wishing to detect and challenge illegal voters."

The State Board of Elections and Ethics Enforcement has already directed all 100 county boards of elections not to hold a challenge hearing or remove any voter from the registration rolls because of a challenge based on a change of residence, board spokesman Pat Gannon said in an email Thursday.

The board also directed counties not to remove any voter from the rolls based on a challenge brought within 90 days of a federal election based solely on generic evidence conveying no information about each challenged voter’s specific circumstances, Gannon said.

Challenges to individual voters in dozens of counties were filed after the 2016 election by Republicans as then-Gov. Pat McCrory fought to close his deficit in the gubernatorial election. Most of those challenges were later dismissed at the county or state level, and McCrory eventually conceded to Democratic Gov. Roy Cooper.