An Indiana county judge ruled Thursday a contested state law that stipulates voting requirements for candidates' party affiliation is unconstitutional, dealing a win to a U.S. Senate hopeful who is seeking to run as a Republican in the primary.

The Marion County judge granted the injunction sought by John Rust, former chair of the egg supplier Rose Acre Farms who is running to replace Sen. Mike Braun. Rust filed a lawsuit in September against Secretary of State Diego Morales, the Indiana Election Commission and Jackson County Republican Party Chair Amanda Lowery to challenge the law and ensure the possibility of his place on the ballot.

The law in question says a candidate’s past two primary elections must be cast with the party the candidate is affiliated with or a county party chair must approve the candidacy. In court documents, Rust argued that this statute "should be struck down as being unconstitutionally vague and overly broad."

ANOTHER REPUBLICAN LAWMAKER RETIRES FROM INDIANA LEGISLATURE

"It is a spectacular victory for the voters of Indiana," Rust said when reached by phone Thursday evening.

Indiana court building

The Marion County Superior Court building is seen in Indianapolis. On Dec. 7, a Marion County, Ind., judge ruled a contested state law that stipulates voting requirements for candidates' party affiliation is unconstitutional, dealing a win to a U.S. Senate hopeful who is seeking to run as a Republican in the primary. (AP Photo/Arleigh Rodgers, File)

It was not immediately clear if the secretary of state will appeal the decision. The Associated Press sent an email to its office and left messages with its attorneys Thursday.

Rust voted as a Republican in the 2016 primary but as a Democrat in 2012. He did not vote in the 2020 Republican primary due to the pandemic and the lack of competitive Republican races in Jackson County, the lawsuit said. Rust said his Democratic votes were for people he personally knew.

Lowery, the county's Republican Party chair, said in a July meeting with Rust that she would not certify him, according to the lawsuit. Rust has said Lowery later cited his primary voting record.

FORMER REPUBLICAN INDIANA AG CURTIS HILL ENTERS 2024 PRIMARY RACE TO REPLACE OUTGOING GOP GOV HOLCOMB

When reached by phone, Lowery said she believes party chairs from both parties will be disappointed by the ruling, and questioned how candidacy can be determined without the primary record. She expects the ruling to be appealed.

In a November hearing, Rust said the law keeps legitimate candidates who have recently moved to Indiana or have switched political identifications from running for office.

In his ruling, Marion County Superior Court Judge Patrick J. Dietrick said the law "unduly burdens Hoosiers’ long recognized right to freely associate with the political party of one’s choosing and to cast one’s vote effectively." He also ordered the defendants to pay Rust's attorney fees.

Rust still faces an uphill challenge for the GOP nomination. U.S. Rep. Jim Banks has received the endorsement of the Indiana Republican Party and former President Donald Trump. Rust must also fulfill a signature quota for the nomination.

Casting himself as a conservative gay man with an "outsider’s voice" to Washington D.C., Rust is the former chair of his family business Rose Acre Farms in southern Indiana. Rose Acre Farms identifies itself as the second-largest egg producer in the U.S.

SELF-DESCRIBED 'GAY CONSERVATIVE' EGG FARMER CHALLENGES JIM BANKS IN INDIANA GOP SENATE PRIMARY

The company was one of four major egg producers in the country accused of fixing the price of eggs in the 2000s. A jury in an Illinois federal court recently ruled the producers conspired to limit the domestic supply of eggs to increase prices between 2004-2008 and ordered the companies to pay $17.7 million in damages.

The ruling inflamed the Senate race. Rep. Banks has accused Rust of being a "conman pretending to be a Republican." Rose Acre Farms has denied any wrongdoing and Rust has said the verdict will be appealed.

Sen. Mike Braun is vacating the seat in his bid for governor.