RALEIGH, N.C. — A federal judge decided Wednesday that partisan primaries must go ahead for North Carolina appellate court races in 2018, partially halting a state law that had canceled them this year.

U.S. District Judge Catherine Eagles in Greensboro said there was no justification from the state or the Republican legislators who passed the cancellation law to hold only free-for-all general elections in November for the statewide judgeships.

But Eagles refused to extend the preliminary injunction sought by Democrats to local trial court seats, saying Republican legislators offered “a legitimate government interest” in eliminating those primary elections because they’ve been debating whether to redraw election districts for District Court and Superior Court.

Eagles said no such interest exists to cancel primaries for three Court of Appeals seats and one Supreme Court seat up for election this year, because those elections are held without specific geographic districts.

Barring any last-minute appeal or further alteration of the law, appellate court candidates can begin filing with other nonjudicial candidates Feb. 12, with primary elections May 8.

“The defendants have made no showing of any governmental interest supporting the abolishment of a mechanism to narrow the field in partisan appellate judicial races,” Eagles wrote.

The state Democratic Party, which sued along with several county Democratic parties to overturn the law approved by the General Assembly in October, praised the ruling but was disappointed its request wasn’t fully granted. Democrats view the law as the state GOP’s latest effort to weaken the judicial branch.

“Make no mistake — this is a major voting rights victory, yet another setback for Republicans’ efforts to rig our judiciary,” state Democratic Party Chair Wayne Goodwin said in a release.

Republican legislative leaders said they were reviewing their legal options and criticized Eagles, nominated to the bench by President Barack Obama, for the decision.

Eagles was also on a three-judge panel that in January ordered changes to North Carolina legislative maps in time for candidate filing. A request by Republicans to block enforcement of that order is pending at the U.S. Supreme Court.

“We are disappointed that this Obama-appointed federal judge is once again injecting chaos and confusion into North Carolina elections at the eleventh hour — this time at the behest of the Democratic Party and to the detriment of voters,” Rep. David Lewis and Sen. Ralph Hise, chairmen of the legislature’s redistricting committees, said in a release.

Democrats argued that their party’s rights of association were damaged by cancelling the primaries because they helped voters rally around their preferred candidate to put on the general election ballot. Otherwise, they said, multiple candidates from the same party will be on ballots, with no way to determine which person is the party’s nominee.

In 2014, 19 people ran for a vacant seat on the Court of Appeals. A state elections board found the race contributed to voter confusion and longer precinct lines, Eagles’ ruling says.

“The burden and likelihood of harm is not speculative,” Eagles wrote.

Eagles wrote that the Democrats’ right to association was burdened but not that severely, referring to arguments by lawyers for Republican leaders and the state that there are methods beyond a primary for a party to choose a favored candidate.

For the trial court seats, state officials could reasonably conclude that holding primaries under current election districts for trial court seats would bring confusion if they approve new district boundaries, according to Eagles.

“The court concludes that the legislature’s explanation is both legitimate and sufficiently weighty to justify the one-time cancellation of the 2018 judicial primaries for Superior and District Court judges,” Eagles wrote.