Poland's ruling party on Saturday dismissed a growing wave of criticism from abroad and worries at home that an overhaul of the Supreme Court would undermine judicial independence.
In the early hours of Saturday senators of the right-wing Law and Justice (PiS) party approved a bill that would end all the terms of Supreme Court justices except those handpicked by the justice minister.
Tens of thousands of protesters had gathered in Warsaw and cities across Poland for candle-lit vigils, chanting "Free Courts" and demanding that President Andrzej Duda, an ally of the PiS, veto the bill. More protests were planned during the day on Saturday.
The government has said the changes will ensure state institutions serve all Poles, not just the "elites", and were needed to make judges accountable.
But the opposition, judges' groups and critics in Brussels say the legislation is a new step by the Polish government towards authoritarianism.
The European Union's executive has given Poland a week to shelve the judicial reforms that Brussels says would put courts under direct government control or risk sanctions.
The United States, Poland's most important ally in NATO, urged Warsaw to make sure that any changes respect the constitution.
"We urge all sides to ensure that any judicial reform does not violate Poland's constitution ... and respects the principles of judicial independence and separation of powers," it said in a statement.
The foreign ministry of Poland - a country that overthrew communism in 1989 and was later seen by many as a model young democracy - said on Saturday it was "surprised" that the United States has decided to voice concerns.
"The fact that the legislative process is still underway makes any such pronouncements premature," the ministry said, adding that the bill protected judicial independence.
The largest US and British organisations of lawyers have disagreed, a stance mirrored by top judges in the Czech Republic, Slovakia and Estonia.
"I have written to the President of Poland ... calling on him to exercise his power of veto over new legislation that will undermine the independence of the Polish judiciary," chair of the Bar of England and Wales, Andrew Langdon, said.
"Judges must be independent. History tells us that justice is not done well when it is influenced by political turbulence and populism," he said.
The European Network of Councils for the Judiciary has said the situation in Poland is "very grave."
Critics point out that PiS senators approved the Supreme Court bill on July 22, the date widely considered to be the start of the communist regime in Poland 73 years ago.
So far only Poland's fellow eurosceptic government in Hungary, led by Prime Minister Victor Orban, has said it will stand by Warsaw in its drive to overhaul the judiciary.
"The inquisition offensive against Poland can never succeed because Hungary will use all legal options in the European Union to show solidarity with the Poles," Orban said in a televised speech in Baile Tusnad, Romania.
An opinion poll for private television TVN showed on Friday that 55 percent of respondents said Duda should veto the judicial overhaul, while 29 percent wanted him to sign it.
Duda's spokesman said on Saturday the president believed there was an inconsistency in the bill, but stopped short of saying what Duda would do.
The president has 21 days to decide whether to sign a bill into law, veto it or send it to the constitutional court for checks.
Earlier this week, Duda demanded that new Supreme Court justices be chosen by a panel composed mostly of judges chosen by a three-fifths parliamentary majority. PiS lawmakers agreed to introduce this change.
The party remains broadly popular among the electorate, despite an upsurge of protest in recent days.