MEXICO CITY (AP) — Mexico’s Senate voted early Wednesday to overhaul the country’s judiciary, clearing the biggest hurdle for a controversial constitutional revision that will make all judges stand for election, a change that critics fear will politicize the judicial branch and threaten Mexico’s democracy.

The approval came in two votes after hundreds of protesters pushed their way into the Senate on Tuesday, interrupting the session after it appeared that Morena, the governing party of outgoing President Andrés Manuel López Obrador, had lined up the necessary votes to pass the proposal.

Judicial employees and law students had protested for weeks, saying the plan, under which all judges would be elected, could threaten judicial independence and undermine the system of checks and balances.

The legislation sailed through the lower chamber, where Morena and its allies hold a supermajority, last week. Approval by the Senate posed the biggest obstacle and required defections from opposition parties.