A federal judge has blocked New Jersey’s unusual “county line” system — used by powerful political machines to help sway Garden State elections — from the June primary.

The decision by U.S. District Judge Zahid Quraishi on Friday came in a suit brought by Andy Kim, now the Democratic frontrunner for U.S. Senate after New Jersey First Lady Tammy Murphy’s decision to drop out last weekend.

Quraishi ruled in favor of Kim and two more plaintiffs — South Jersey congressional candidates Sarah Schoengood and Carolyn Rush — issuing a preliminary injunction that forces clerks in the 19 New Jersey counties that use the “line” system to redesign ballots before the election. There are 21 counties total in the state.

The county line system has long been at the center of New Jersey politics, serving as a way of signaling to voters which candidates party machines consider legitimate. Critics, including Kim, say it protects entrenched political interests at the expense of reformers and upstart candidates in a state long dogged by corruption and dominated by the power of political elites. Placement on the line is awarded through endorsements by county political party committees.

“This is a political earthquake that can change [New Jersey’s] political landscape forever,” Jeff Tittel, a longtime political activist and former head of New Jersey’s chapter of the environmental nonprofit Sierra Club, said on Friday.

He called it a major move “forward in reforming our corrupt political system” and the product of “a long battle been the [political party] bosses and good government.”

The race for the Senate seat currently held by Sen. Bob Menendez, who has pleaded not guilty to federal corruption charges, has been a proxy battle over the line.

“Today's decision is a victory for a fairer, more democratic politics in New Jersey," Kim said in a statement sent by his campaign. "It's a victory built from the incredible grassroots work of activists across our state who saw an undemocratic system marginalizing the voices of voters, and worked tirelessly to fix it.”

Murphy had been set to get the coveted ballot position in two-thirds of the state — in many cases thanks only to the say-so of political committee chairs.

Kim and other opponents of the line argued that Murphy, as first lady, had an even greater institutional advantage than most establishment candidates. They said the county’s political chairs, some of whom have state jobs or do business with the state, had a strong interest in remaining in the good graces of the state’s governor.

But Murphy dropped out of the race on Sunday, and in the aftermath, Kim agreed to accept endorsements from most of the party county committees in New Jersey — meaning he’d benefit from the same system he opposed.

Quraishi’s decision “essentially means that New Jersey voters and the plaintiffs will have a fair primary election for the first time in probably a century, making history,” Kim’s attorney Yael Bromberg said.

She called the ruling “a resounding victory for New Jersey voters and for the plaintiffs.”

The clerks defending the county line in court were evaluating whether to appeal the decision, their attorney John Carbone said in a statement.

“With ballots required to be printed in one week and voting starting in 20 days, many County Clerks have significant concerns about the feasibility of compliance with the Court’s order,” he wrote.

Quraishi wrote in his decision that he “recognizes [its] magnitude," with the “integrity of the democratic process for a primary election” at stake.

Under the county line system, candidates running on a ticket or slate are bracketed together in a single line or row. As a result, candidates endorsed by county political organizations, for any office, all appear on a line together. This year, that line will be headed by President Joe Biden.

Researchers say voters are inclined to tick off all the boxes in that line, which appears more legitimate because of the associations with candidates in major races. One study found a double-digit advantage for congressional candidates running on the line, across 45 races.

Under Quraishi’s order, counties will instead have to use an “office block” ballot format, where all candidates for a given office are grouped together.

Clerks defending against the line had argued in court that changing the ballot system so close to an election would be difficult, and that striking it would interfere with candidates’ and political committees' free association rights.

But Quraishi pushed back on the timing argument, and in his ruling said county parties don’t need to use special ballot placements to endorse candidates. The current system gives some candidates an “arbitrary advantage” and creates voter confusion, he wrote.

Over the last few weeks, some of New Jersey’s most powerful political figures made dramatic statements that they were open to changing the longstanding county line system. They included the state's Democratic Party chair, LeRoy Jones, who also chairs Essex County’s Democratic Committee. His county has one of the largest counts of registered Democrats in New Jersey, and he was expected to award Essex’s line to Murphy until she dropped out.

Legislative leaders from both parties recently said they too would start a “public process” to revisit New Jersey’s ballot design. On Friday, they said were reviewing the court decision but still believed "the Legislature is the appropriate body to remedy" any constitutional issues with the state's balloting process.

New Jersey Attorney General Matthew Platkin made a sharp break from Gov. Phil Murphy earlier this month, saying he wouldn’t help defend against Kim’s lawsuit challenging the county line — calling the line an “undemocratic” ballot design. Murphy has defended the line as a useful way to allow experienced party chairs to vet the candidates most likely to win general elections.

It’s unclear what the ruling will mean for a separate lawsuit against the county line that was first filed in 2020. But the state chapter of the Working Families Party, which is a party in that suit, celebrated Quraishi’s ruling on Friday.

“Candidates will now be answerable to voters at the ballot box — not corporate special interests who control the awarding of the line,” New Jersey WFP Director Antoinette Miles said.

Henal Patel, law and policy director at the nonprofit New Jersey Institute for Social Justice, called the ruling “amazing” and a “huge win for democracy.” The organization had opposed the county line system and filed briefs for several racial justice organizations in support of Kim’s lawsuit.

“It's a new day for democracy in New Jersey," Patel said. "The county line has been an affront to our democracy for decades. It dilutes our votes. It disempowers."

Kim has positioned himself as a good-government reformer in his bid for Menendez's seat. The senator faces a federal indictment alleging he took bribes in exchange for helping foreign governments and tried to interfere in criminal cases. Menendez has said he hopes to run as an independent after fighting the charges in court.

Kim faces two other Democrats in the primary — activists Larry Hamm and Patricia Campos-Medina. Hotel entrepreneur Curtis Bashaw, Mendham Mayor Christine Serrano Glassner and Tabernacle resident Justin Murphy will compete in this year's Republican primary.

This story has been updated with additional information.