Judge P. Kevin Brobson of Commonwealth Court in Harrisburg noted that Republicans hold 13 out of 18 Congressional seats in Pennsylvania, a perennial swing state that has one of the most extensively gerrymandered maps in the country. Nonetheless, the judge said that Democrats who brought suit had failed to articulate a legal “standard” for creating nonpartisan maps.

The case now goes to the Pennsylvania Supreme Court, which has agreed to fast-track it. If the court rejects Judge Brobson’s conclusion, it could order new maps drawn in time for the 2018 midterm elections. Pennsylvania is expected to be fiercely fought terrain next year in elections turning on President Trump’s popularity. Mr. Trump’s 2016 victory in the state was the first for a Republican presidential candidate since 1988, but Republicans are already worried about losing Congressional seats even without new maps.