In a big win for voting rights, a federal court has ordered Kansas to begin registering thousands of eligible voters who had been kept off the rolls by the state’s strict proof of citizenship law.

The order, issued Tuesday evening by U.S. District Court Judge Julie Robinson, affects around 18,000 would-be voters who tried to register through the state’s Department of Motor Vehicles. Their registrations had been kept in limbo because they didn’t provide proof of citizenship as required by a 2011 Kansas law.

“This ruling lifts the barrier that the state illegally imposed on Kansans who were trying to register to vote,” said Dale Ho, the director of the ACLU’s voting rights project, which brought the case. “It means thousands of people who could have been sidelined during the upcoming primary and general election will be able to participate.”

The ACLU’s lawsuit claimed that by not registering voters who signed up at the DMV, Kansas was violating the 1993 National Voter Registration Act, which aims to make registration as easy as possible, especially at public assistance agencies like the DMV. The court didn’t rule on the merits of the claim, but it found that the ACLU is likely to succeed on the merits, so it issued an injunction ordering the state to begin registering those voters June 1.

Importantly, it said that Kansas could use a less burdensome means of ensuring that all registered voters are citizens: by requiring them to attest to that on penalty of perjury, as the federal voter registration form already requires.

“Without the injunction, approximately 18,000 Kansas motor voter registration applicants will be precluded from registering to vote solely based on their failure to provide [proof of citizenship],” wrote Judge Robinson.

About half of all voter registration applications come through the DMV, so the ruling weakens the proof of citizenship law as a whole. And it’s a blow to Kansas Secretary of State Kris Kobach, the defendant in the lawsuit, who has championed the law and fought for its enforcement.

Kobach, a Republican, claims it’s needed to stop non-citizens from voting. But Robinson wrote that Kansas could point to only three illegal voters and 14 illegal registrants between 1995 and 2013.

“On this record, the Court cannot find that the State’s interest in preventing noncitizens from voting in Kansas outweighs the risk of disenfranchising thousands of qualified voters,” Robinson wrote.

Kobach said Tuesday he’ll file an emergency appeal to the 10th Circuit Court of Appeals.

Kobach has been seeking to toss out around 30,000 voter registration applications submitted by people who didn’t provide proof of citizenship. The sprawling controversy has also ensnared the federal agency that helps states run elections, known as the Election Assistance Commission. A Kobach ally who serves as the agency’s executive director in January approved Kobach’s request to change the instructions that accompany the federal voter registration form to add a proof of citizenship requirement for Kansas and two other states. That move, too, is being challenged by the ACLU and others.