Pennsylvania Democrats had their best chance in years this election to take control of one or both houses of the state legislature.

They came up well short of that goal, as Republicans expanded their majority in the House — even defeating the Democratic minority leader in that chamber — and retained control of the Senate.

Despite the setback, Democrats will still play a significant role next year in drawing new congressional and state legislative maps in accordance with decennial redistricting.

The party is in a much better position than it was in 2011, when Republicans held the legislature, the governor’s office, and a majority on the state Supreme Court.

This time, the Democrats have Gov. Tom Wolf, who could veto a congressional map sent to him by the GOP-controlled legislature. Perhaps even more important, Democrats have a 5-2 majority on the Supreme Court.

That will almost certainly give the party an advantage in drawing new state legislative maps for the 203 districts in the House and 50 in the Senate.

That process is controlled by a five-member commission that includes the four floor leaders in the General Assembly — two from each party. If they can’t agree on a fifth member, that person is chosen by a majority of the Supreme Court.

“I think it presents an opportunity to get fair maps,” said State Sen. Jay Costa (D., Allegheny), the Democratic minority leader. Courts have “laid out a road map as to what you can and can’t do,” Costa said, limiting the impact of gerrymandering.

The Pennsylvania Supreme Court made national headlines in 2018 when it threw out the state’s old congressional map, declaring it an unconstitutional partisan gerrymander drawn to discriminate against Democrats, and imposed a new one in time for the midterm elections. The GOP went from holding a 13-5 edge in the congressional delegation to a 9-9 tie.

Nancy Patton Mills, chairwoman of the Pennsylvania Democratic Party, said the 2018 results showed that when the maps are fair, “we know then that we can win.”

Unlike legislative reapportionment, congressional redistricting follows the normal legislative process, in which both chambers pass a bill that can be signed or vetoed by the governor.

In 2011, three dozen Democrats — mostly from Philadelphia and Pittsburgh — voted with Republicans in favor of the congressional map struck down by the Supreme Court in 2018.

The court’s 2018 decision will loom over the redistricting process, and may well encourage Republican lawmakers to seek a compromise with Wolf.

But it could be hard to get Wolf and GOP leaders in the same room, given their months-long feud over the governor’s use of emergency powers during the pandemic.

“I think the adversarial relationship between the legislature and the governor right now can’t be discounted,” said Charlie Gerow, a Harrisburg-based GOP strategist.

But, he added, “The legislature might prefer to agree with the governor than fight with the court.”

That underscores the enduring significance of the 2015 Supreme Court elections, when big spending by building trades unions and trial lawyers helped Democrats win all three open seats and erase a Republican majority.

Outraged by the court’s 2018 decision, some House Republicans unsuccessfully moved to impeach Democratic justices. A GOP lawmaker from Lancaster County renewed the effort to impeach Democratic Justice David Wecht last month, citing his rulings against GOP attempts to terminate Wolf’s COVID-19 emergency powers and other decisions.

In addition, Republicans have advanced a constitutional amendment that would change the way the state chooses appeals court judges, replacing statewide elections with regional elections.

Supporters say this would lead to greater geographic diversity on the courts, while opponents say it would undermine judicial independence by allowing lawmakers to draw judicial districts. The amendment passed both houses of the legislature earlier this year, and could appear on the ballot as early as May 2021 if lawmakers pass it again next year.

Perhaps the most significant development with next year’s reapportionment is that Pennsylvania is expected to lose one of its 18 seats in Congress due to national population trends, further eroding the state’s influence in Washington. Pennsylvania had a peak of 36 seats after the 1910 census.

The state’s share of Electoral College votes would fall from 20 to 19.

Harrisburg observers are closely watching how that will affect the congressional map. Several incumbents won reelection this month in tight races, and even small changes in their districts could make all the difference between another two-year term and a forced change in career plans.

For example, Democrats see Rep. Conor Lamb, of Allegheny County, as a rising star, but it’s entirely possible that the new map could merge his district with fellow Democratic Rep. Mike Doyle.

Depending on the outcome, some representatives with an eye on higher office might run for U.S. Senate or governor in 2022.

» READ MORE: U.S. Rep. Conor Lamb on Pennsylvania politics and the future of the Democratic Party

It’s unclear when the redistricting process will start.

Every 10 years, the Census Bureau conducts a new population count that determines the number of representatives apportioned to each state in Congress. Under federal law, the Census Bureau is required to deliver the apportionment count to the president by Dec. 31. The bureau is supposed to send redistricting data to the states by April 1.

But census delays caused by the coronavirus pandemic, combined with litigation over President Donald Trump’s effort to remove noncitizens from the count, may upend that timeline — not to mention the count itself.

Even in normal circumstances, the process can take a while. The state Supreme Court rejected the GOP-led Legislative Reapportionment Commission’s initial plan in 2012. The court approved a modified plan in 2013, and the new state map didn’t take effect until the 2014 elections.

Nonpartisan good-government groups and some lawmakers have tried to change the redistricting process so that the maps are drawn by an independent commission, not lawmakers. But the proposed reforms haven’t been adopted so far.

Patrick Beaty, legislative director of Fair Districts PA, said his group will continue to push for those changes. Even if the law doesn’t change before redistricting, he said he’s optimistic the maps will be fairer this time.

“Even though they technically have the same ability to gerrymander as they have in the past,” he said of lawmakers, that’s less likely to happen now “because of all the attention that’s been brought to this issue.”

Correction: A previous version of this story incorrectly said Republicans had regained control of the state Senate in November’s elections. The GOP already held a majority.