Pennsylvania’s mail-voting law is constitutional, the state Supreme Court ruled Tuesday, upholding the 2019 measure that allows any voter to use mail ballots and removing a cloud of uncertainty heading into the midterm elections.

The law dramatically expanded mail voting from a method that had been allowed only in a very small number of cases — about 5% of votes in any given election — to one used by millions over the last two years.

It was the product of bipartisan negotiations between Democratic Gov. Tom Wolf and Republicans who control the state legislature, the biggest change to Pennsylvania election law in generations. But its implementation in 2020 came during both the first year of the pandemic and a heated presidential election. As massive numbers of voters cast ballots by mail, state and county elections officials tried to build out the system — in some cases triggering Republican outrage and lawsuits over their decisions.

That was further stoked by then-President Donald Trump, who began attacking mail voting months before his loss to Joe Biden in the 2020 presidential election. Republicans have continued to try to dismantle the law known as Act 77, with some saying it has been abused in its implementation, and others espousing bogus conspiracy theories about widespread fraud.

The resulting partisan divide over a mail voting law that had been carefully negotiated — and trumpeted — by both Democrats and Republicans was on full display following the ruling Tuesday.

“I will continue to advocate for voting reforms that remove barriers and increase access to voting,” Wolf said in a statement as Democrats and allied groups applauded the court.

House Republicans’ point person on elections, meanwhile, suggested the elected Democrats who make up the court’s majority were acting as partisans. And the spokesperson for Senate Republicans said the ruling “underscores the importance of the actions taken by the General Assembly to strengthen election integrity,” including moving to add strict voter ID requirements to the state Constitution.

» READ MORE: Fights over Pa. election rules that seemed settled after 2020 have now come roaring back

Partisanship helped create Act 77 in the first place, with bipartisan negotiations taking place in 2019 only after Wolf and Republican lawmakers repeatedly butted heads over election legislation and funding for new voting machines.

Constitutional questions also swirled around the law from the very beginning.

Pennsylvania’s Constitution explicitly describes situations allowing absentee voting, including for disabled voters and those who will be out of town on Election Day. Because of that, the legislature couldn’t simply expand absentee voting. Instead, Act 77 created a “mail-in” ballot that was the same as an absentee ballot. That created two functionally identical types of mail ballots — and lawmakers further blurred the lines between the two in a separate bill they passed in March 2020.

A group of Republican lawmakers — some of whom voted for the law in 2019 — and a Republican county commissioner sued last summer, saying Act 77 violates the state Constitution. The state Constitution’s protection of absentee voting, they argued, means it’s unconstitutional to provide mail voting in other cases.

Their argument also centered on the requirements for voter eligibility, which include that “he or she shall have resided in the election district where he or she shall offer to vote at least 60 days immediately preceding the election.”

That “offer to vote” language means voters must cast ballots in person unless they fall within the constitutional exception for absentee voting, Republicans argued, relying on two 1862 and 1924 cases.

The state Commonwealth Court agreed with that argument and temporarily struck down Act 77 in January. The state appealed to the Pennsylvania Supreme Court, which stayed the ruling and kept the law in place while it considered the case.

» READ MORE: Another election is coming and there’s still uncertainty around Pennsylvania’s mail voting law

The high court heard arguments in early March. Since then, officials and lawyers have waited for a ruling they knew could come at any time and had the potential to either affirm the status quo — or significantly disrupt the electoral system.

On Tuesday, the court dropped its ruling: Act 77 didn’t overstep the Constitution in expanding mail voting, and the law remains on the books.

“We reiterate that our General Assembly is endowed with great legislative power, subject only to express restrictions in the Constitution,” Justice Christine Donohue wrote for the majority. “We find no restriction in our Constitution on the General Assembly’s ability to create universal mail-in voting.”

Donohue was joined by Chief Justice Max Baer and Justices Debra Todd and Kevin Dougherty; a fifth justice, David Wecht, agreed with most of the opinion. All five were elected as Democrats.

They rejected the argument that previous court cases required them to limit mail voting only to the explicitly protected absentee voters. Walking through the history of the Constitution and absentee voting, the court reasoned that absentee voters are the minimum protected group of voters allowed to vote by mail — but that nothing bars the legislature from giving that option to others.

The two elected Republicans on the court, Justices Sallie Updyke Mundy and Kevin Brobson, dissented. Both argued the court was improperly recasting history — and prior precedent — to protect the law.

“Succinctly stated, the majority overrules 160 years of this Court’s precedent to save a law that is not yet 3 years old,” Brobson wrote. “It does so not to right some egregiously wrong decision or to vindicate a fundamental constitutional right.”

Mundy emphasized that her disagreement with the Democratic majority was about law and precedent, not policy or politics.

“I express no opinion as to whether no-excuse mail-in voting reflects wise public policy,” Mundy wrote. “That is not my function as a member of this state’s Judiciary. My function is to apply the text of the Pennsylvania Constitution, understood in light of its history and judicial precedent. In so doing, I would hold that that venerable document must be amended before any such policy can validly be enacted.”

Tuesday’s decision is unlikely to dampen the partisan fighting over Pennsylvania elections.

The same Republican lawmakers who sued over Act 77 filed a second lawsuit in July, arguing that the law should be struck down on entirely separate grounds based on recent federal court rulings. Responses to that lawsuit are due Monday.