The Supreme Court’s ruling that two North Carolina congressional districts relied too heavily on race should give voting-rights advocates a potent tool to fight other electoral maps drawn to give Republicans an advantage in the state.

The justices agreed Monday with a federal court that had struck down two congressional districts as illegally race-based. Because those districts were already redrawn for the 2016 election, the ruling doesn’t require immediate changes from North Carolina. But it looms large in other battles unfolding over voting districts there and elsewhere.

Also pending before the high court is a separate challenge to North Carolina state House and Senate districts that have helped the GOP cement veto-proof majorities in both chambers.

A lawyer challenging the General Assembly districts said legislative mapmakers used similar reasoning to defend the congressional and legislative maps, so Monday’s ruling bolsters her cause.

“It’s abundantly clear that what the state of North Carolina did in drawing its legislative districts cannot withstand constitutional muster,” Anita Earls of the Southern Coalition for Social Justice said in a phone interview.

In the case Ms. Earls is arguing, a federal court had previously thrown out 28 state House and Senate districts as illegal racial gerrymanders. But earlier this year the Supreme Court temporarily halted an order to redraw those legislative districts. The justices could act on the challenge to the state districts as early as next week.

In recent years, the Supreme Court has ruled for civil rights groups and black voters in challenges to political districts in Alabama, North Carolina, and Virginia.

A Democratic group led by former Attorney General Eric Holder is focusing on redistricting challenges to counter political gains Republicans have made since the 2010 census and the redrawing of electoral districts that followed.

Marc Elias, who argued the case decided Monday and is a senior adviser to Mr. Holder’s group, said the ruling “will serve as a warning to Republicans not just in North Carolina but throughout the country that their cynical efforts to use race will not go unchallenged.”

States have to take race into account when drawing maps for legislative, congressional, and a host of municipal political districts. At the same time, race can’t be the predominant factor without very strong reasons, under a series of high court decisions.

A legal scholar who studies elections law said Monday’s ruling should help voting-rights activists show that partisan motives can’t shield legislative mapmakers from accusations of relying too much on race.

“This will lead to many more successful racial gerrymandering cases in the American South and elsewhere,” Rick Hasen of the University of California-Irvine wrote Monday on his blog.

North Carolina’s congressional map was redrawn for the 2016 elections after the two districts were struck down by a federal court. But even with the new districts, Republicans maintained their 10 to 3 edge in congressional seats. Challenges to those new districts are pending, based on arguments that politics played too much of a role in their creation.

On Monday, the justices ruled that Republicans who controlled the state legislature and governor’s office in 2011 placed too many African-Americans in the two congressional districts. The result was to weaken African-American voting strength elsewhere in North Carolina.

Justice Elena Kagan, writing for the court, said the state did not offer compelling reasons to justify its reliance on race in either district.

The court unanimously affirmed the lower court ruling on District 1 in northeastern North Carolina. Ms. Kagan wrote that the court will not “approve a racial gerrymander whose necessity is supported by no evidence.”

The justices split 5 to 3 on the other territory, District 12 winding from Charlotte to Greensboro. Justice Neil Gorsuch did not take part in the case.

The state insisted that race played no role at all in the creation of one district. Instead, the state argued that Republicans who controlled the redistricting process wanted to leave the district in Democratic hands, so that the surrounding districts would be safer for Republicans.

“The evidence offered at trial ... adequately supports the conclusion that race, not politics, accounted for the district’s reconfiguration,” Kagan wrote.

The court action comes at a time of intense political division in the state, highlighted by legal battles over the GOP-controlled legislature’s efforts to pass laws limiting some powers of North Carolina’s new Democratic governor, Roy Cooper.

Mr. Cooper issued a statement applauding the Supreme Court for supporting “a level playing field and fair elections” for voters.

“The North Carolina Republican legislature tried to rig Congressional elections by drawing unconstitutional districts that discriminated against African Americans and that’s wrong,” Cooper said.

But Robin Hayes, the North Carolina GOP chairman, said court rulings on redistricting have put legislative mapmakers “in an impossible situation, with their constantly changing standards.”