The U.S. Supreme Court could radically change how states draw their districts for federal and state elections as Republicans and Democrats are preparing to battle over the next redistricting cycle.

More than 30 years ago, the high court said that considering party affiliation too much in redistricting could cross the line into unconstitutional gerrymandering. But the Supreme Court provided little guidance and federal courts have since struggled to find where that line is.

As a result, states defending allegations that...