SPRINGFIELD, Ill. (AP) — A judge on Wednesday rejected a law Illinois Democrats adopted last month that prohibits political parties from drafting candidates when no one was on the party primary ballot.

Sangamon County Circuit Judge Gail Noll ruled the law, drawn to protect vulnerable Democrats in November’s general election, is unconstitutional. It improperly interferes with a person’s right to see access to the ballot and that, Noll wrote, “places a severe restriction on the fundamental right to vote.”

“Plaintiffs have a clearly ascertainable right to be free from unconstitutional restriction on their right to vote which under the circumstances of this case includes their right to ballot access,” Noll’s opinion said.

Previously, someone who wasn’t on the primary ballot — this year, March 19 — could still run in November after getting the nod from party leaders and collecting the requisite number of valid petition signatures by the June 3 deadline set by the Illinois State Board of Elections.

Several of those Republican candidates filed the lawsuit. The elections board has continued to accept nominating petitions.

Democrats who approved the change in early May said a candidate for public office should face the voters, not be hand-picked after finding out post-primary what the competition will be. Democratic Gov. J.B. Pritzker called it an ethics law.

But Republicans blasted the idea, particularly because it was done in the middle of an election cycle. Senate Minority Leader John Curran, a Republican from the Chicago suburb of Downers Grove, called on Pritzker to suspend legal action in the matter and allow Republicans to proceed under the former law.

“Gov. Pritzker’s deceitful framing of this legislation as ethics reform defied logic at the time and sought to cover up his willingness to assault the constitutional rights of Illinoisans in the Democrats’ quest for power at all costs,” Curran said in a statement.

In the ruling, Noll noted that Attorney General Kwame Raoul, defending the General Assembly and Pritzker, said the government interest is to “prevent political insiders from having control over which candidates are slated,” allowing voters to make those choices.

The judge found that there are less restrictive ways to achieve that goal, a requirement of preceding case law.

An emailed messaged seeking comment was left with Raoul’s spokesperson.