Congress on Friday gave final passage to legislation changing the arcane law that governs the certification of a presidential contest, the strongest effort yet to avoid a repeat of Donald Trump’s violence-inflaming push to reverse his loss in the 2020 election.

The House passed an overhaul of the Electoral Count Act as part of its massive, end-of-the-year spending bill, after the Senate approved identical wording Thursday. The legislation now goes to President Joe Biden for his signature.

Biden hailed the provisions’ inclusion in the spending bill in a statement Friday, calling it “critical bipartisan action that will help ensure that the will of the people is preserved.”

It’s the most significant legislative response Congress has made yet to Trump’s aggressive efforts to upend the 2020 election results, and a step that been urged by the House select committee that conducted the most thorough investigation into the violent siege of the Capitol.

The provisions amending the 1887 law — which has long been criticized as poorly and confusingly written — won bipartisan support and would make it harder for future presidential losers to prevent the ascension of their foes, as Trump tried to do on Jan. 6, 2021.

“It’s a monumental accomplishment, particularly in this partisan atmosphere, for such a major rewrite of a law that’s so crucial to our democracy,” said Rick Hasen, a law professor at the University of California Los Angeles. “This law goes a long way toward shutting down the avenues Trump and his allies tried to use in 2020, and could have been exploited in future elections.”

On Jan. 6, Trump targeted Congress’ ratification of the Electoral College’s vote. He tried to exploit the vice president’s role in reading out the states’ electors to get Mike Pence to block Biden from becoming the next president by omitting some states Biden won from the roll. The new provisions make clear that the vice president’s responsibilities in the process are merely ceremonial and that the vice president has no say in determining who actually won the election.

The new legislation also raises the threshold required for members of Congress to object to certifying the electors. Before, only one member of the House and Senate respectively had to object to force a roll call vote on a state’s electors. That helped make objections to new presidents something of a routine partisan tactic — Democrats objected to certifying both of George W. Bush’s elections and Trump’s in 2016.

Those objections, however, were mainly symbolic and came after Democrats had conceded that the Republican candidates won the presidency. On Jan. 6, 2021, Republicans forced a vote on certifying Biden’s wins in Arizona and Pennsylvania even after the violent attack on the Capitol, as Trump continued to insist falsely that he won the election. That led some members of Congress to worry the process could be too easily manipulated.

Under the new rules, one-fifth of each chamber would be required to force a vote on states’ slates of electors.

The new provisions also ensure only one slate of electors makes it to Congress after Trump and his allies unsuccessfully tried to create alternative slates of electors in states Biden won. Each governor would now be required to sign off on electors, and Congress cannot consider slates submitted by different officials. The bill creates a legal process if any of those electors are challenged by a presidential candidate.

The legislation would also close a loophole that wasn’t used in 2020 but election experts feared could be, a provision that state legislatures can name electors in defiance of their state’s popular vote in the event of a “failed” election. That term has been understood to mean a contest that was disrupted or so in doubt that there’s no way to determine the actual winner, but it is not well-defined in the prior law.

Now a state could move the date of its presidential election — but only in the event of “extraordinary and catastrophic events,” like a natural disaster.

Hasen said that while the changes are significant, dangers still remain to democracy, noting that in Arizona, the Republican nominee for governor, Kari Lake, was waiting on a ruling Friday in a lawsuit she filed to overturn the victory of her Democratic opponent, Katie Hobbs.

“Nobody should think that passage of this legislation means we’re out of the woods,” Hasen said. “This is not one and done.”