New York’s highest court ordered the state to redraw its congressional map on Tuesday, delivering a ruling that offers Democrats a new weapon to wrest control of the House from Republicans in 2024.

The decision could have far-reaching implications in reshaping the House battlefield in a key state. New York Democrats are widely expected to use the opening to try to shift two to six Republican-held swing districts that President Biden won, from Long Island to Syracuse.

The State Constitution still prohibits partisan gerrymandering. But Democrats would need to make only slight alterations to the district lines to improve the party’s chances and imperil Republicans’ three-seat majority before the campaign season even begins.

“They might have won two or three of those Biden districts back anyway — now it might be five or six,” said Dave Wasserman, an elections analyst with the Cook Political Report. “When you are talking about such a narrow majority in the House, obviously that’s a big deal.”

The 4-to-3 ruling by the State Court of Appeals effectively wiped out the highly competitive districts that helped Republicans flip four seats and seize the House last year. That map had been drawn by a special master after the courts threw out an earlier Democratic map because it ran afoul of state gerrymandering laws.

The judges on Tuesday said the map was meant to be temporary, and ordered the state to restart a process that would ultimately empower the Democratic-led State Legislature to reshape the contours of the state’s 26 congressional districts.

Democrats celebrated the decision. But top Republicans in New York and Washington vowed to challenge any new map that they believe violates the gerrymandering ban, raising the specter of yet another protracted legal battle early next year.

“The decision today opens the door for Democrats to rig our congressional district lines so that elections are decided not by the voters, but by politicians in a back room,” read a joint statement from Representative Elise Stefanik, the top New York Republican in the House, and Edward F. Cox, the party’s state chairman.

The pair said the ruling had left the court’s reputation “in tatters.”

The case in New York was one of the final disputes outstanding across the country in an unusually active round of legal challenges stemming from last year’s decennial redistricting cycle. Based on past voter trends, the outcome now appears likely to give Democrats a slight national advantage over Republicans.

The Supreme Court and other federal judges had already ordered several Republican-led states to redraw maps that had diluted the power of Black voters. The changes could net Democrats two to three seats in the Deep South.

Tuesday’s decision could also offset recent Republican redistricting gains in North Carolina, where a new conservative majority on the state Supreme Court cleared the way for an aggressive gerrymander that could net Republicans three to four seats.

The New York dispute dates to early 2022, when nearly every state was redrawing its House districts based on population shifts in the 2020 census.

New York voters had adopted a constitutional amendment empowering a bipartisan redistricting commission to do that job, but the panel deadlocked and failed to finish its work. The Democrat-dominated State Legislature proceeded to adopt its own map.

After Republicans sued, the Court of Appeals found that the Democrats’ plan was an unconstitutional gerrymander and had violated the constitutional amendment.

The court then hired a neutral special master to draft a replacement map. Competing on those lines last November, Republicans flipped four districts to claim 11 of the state’s 26 House seats.

A group of New York voters brought the current suit not long afterward, asking the court to return the mapmaking process to the commission and the State Legislature, ostensibly to give fellow New Yorkers a greater say in the district boundaries.

But the partisan motivation was always clear: The suit was paid for by the Democratic Congressional Campaign Committee in Washington and argued by Elias Law Group, which has long been the favored firm of Democrats in Congress.

Republicans strongly opposed the effort. They made technical arguments about the timing of the Democrats’ suit and a constitutional provision that they argued prohibited redrawing district lines mid-decade. A Republican lawyer stated their objections most clearly in oral arguments last month: Democrats had not learned their lesson, he said, and would undertake “a festival of gerrymandering” if the court let them have another shot at the map.

The Court of Appeals made clear on Tuesday that it was not persuaded by those arguments. It ordered the redistricting commission to promptly reconvene to produce a new proposal by no later than Feb. 28.

The panel, which is evenly divided between Republicans and Democrats, could theoretically agree on a new map or could present competing partisan plans. Its top Democrat and Republican appointees accepted the decision on Tuesday and vowed to try to work toward common ground.

But the New York Constitution affords the Legislature final authority to accept, reject or modify any commission proposal. And Democrats who enjoy supermajorities there are unlikely to adopt any map that does not improve their candidates’ electoral chances, at least to to some degree.

Representative Hakeem Jeffries of New York, the top House Democrat and one of the leading critics of the court-drawn map, praised the court’s reversal as an “enlightened decision.”

“The New York State Court of Appeals has affirmed that the current congressional district lines drawn by an unelected, out-of-town special master undercut the will of New York voters,” he said in a statement. He said new maps would give them “an opportunity to elect the representation they deserve.”

The majority opinion turned largely on technical constitutional questions that differed from the ones before the body in April 2022. But the sharp turnabout in outcome also coincides with significant changes to the panel since that ruling.

Janet DiFiore, a moderate jurist, retired as chief judge last summer, not long after writing the majority decision chastising the Democratic Legislature. Chief Judge Rowan D. Wilson, her more liberal replacement, dissented in that case and has taken a far more expansive view of the role of the State Legislature in redistricting.

“The people of New York are entitled to the process set out in the Constitution,” Judge Wilson wrote in a majority opinion on Tuesday that largely sidestepped questions of partisanship.

The three judges who dissented from Tuesday’s ruling — Michael J. Garcia, Madeline Singas and Anthony Cannataro — had all joined Judge DiFiore in the majority last time. All seven members of the bench were appointed by Democratic governors.

Judge Cannataro laced into his colleagues in a blistering 27-page dissent, arguing that the court had no justification to overturn its earlier decision.

“This time, however, politics triumphs over free and fair elections,” he wrote.

It could now take several months for New York to adopt new district lines, leaving lawmakers in both parties in limbo.

Democrats are not necessarily expected to try to return to the kind of aggressive gerrymander that the court shot down in 2022. Lawmakers in Albany could either draw their own, less drastic alternative or simply accept a plan drawn up by Democratic members of the redistricting commission to avoid accusations of gerrymandering.

Either way, Republicans clearly have more to lose.

They were already defending six districts Mr. Biden won across the state, including those represented by the first-term congressmen Anthony D’Esposito and Nick LaLota on Long Island, Mike Lawler in the Lower Hudson Valley, Marc Molinaro in the Catskills and Brandon Williams around Syracuse.

“This politically motivated decision is just the beginning of this process,” Mr. Lawler said. “Not the end.”