The decision marks a notable victory for Democrats, who are trying to counter a Republican redistricting movement advanced by President Donald Trump.