Open this photo in gallery Protesters shout slogans as they attend a demonstration in support of Supreme Court judges in front of the Supreme Court in Warsaw, on July 3, 2018. JANEK SKARZYNSKI/Getty Images

Poland’s government carried out a sweeping purge of the Supreme Court on Tuesday night, eroding the judiciary’s independence, escalating a confrontation with the EU over the rule of law and further dividing the country. Tens of thousands took to the streets in protest.

Poland was once a beacon for countries struggling to escape the yoke of the Soviet Union and embrace Western democracy. But it is now in league with neighbouring countries, such as Hungary, whose leaders have turned to authoritarian means to tighten their grip on power, presenting a grave challenge to a European Union already grappling with nationalist, populist and anti-immigrant movements.

The forced retirements of up to 27 of 72 Supreme Court justices, including the top judge, and the creation of a judicial disciplinary chamber were the latest in a series of steps by Poland’s right-wing Law and Justice Party to take over the justice system.

Story continues below advertisement

For years, the party has demonized judges as unreconstructed communists and obstructionists. After coming to power in 2015, it took control of the Constitutional Tribunal, which is tasked with ensuring that laws do not violate the constitution, and gave authority over the country’s prosecutors to the Ministry of Justice. Most recently, it asserted new powers to select judges. In recent days, judges who have spoken out against the changes have reported being harassed and intimidated.

Each move has been greeted with international condemnation and angry demonstrations.

Hours before the purge took effect at midnight, Poles again took to the streets in more than 60 cities and towns around the country. As the sun set in Warsaw, crowds gathered in front of a memorial dedicated to those who died in the city’s 1944 uprising against Nazi Germany, chanting an old but familiar refrain: “Solidarnosc.”

But now, calls for solidarity were not directed at an occupying force – or at communist rule, which the labour-backed Solidarity movement brought down in 1989 – but at a democratically elected government, albeit one the demonstrators fear is undermining the system they fought so hard to build.

“We are here because of the destruction of the judiciary in Poland,” said Kamila Wrzesinska, who stood amid a sea of Polish and EU flags. Organizers passed out placards with one word: “Constitution.”

In an interview just days ago, the leader of the Supreme Court, Malgorzata Gersdorf, expressed deep concern about her country’s direction.

“I don’t want to say that I am terrified,” she said, “but without a doubt this is not a direction I would like to go in, nor support, as I think it destroys what has been built over the last 25 years.”

Story continues below advertisement

The new law passed by parliament requires that judges retire when they turn 65 unless they appeal to the country’s President, Andrzej Duda, who has sole discretion over whether they can remain.

Justice Gersdorf, who is 65, and more than a dozen others have refused to make such appeals, saying that the law itself was unconstitutional. Their supporters say the law was aimed at certain judges and had little to do with age, an argument that was bolstered when the government named Justice Gersdorf’s replacement: the 66-year-old judge Jozef Iwulski.

The ousted justices vowed to show up for work Wednesday morning, setting the stage for a possible confrontation with the authorities.

Officials with the governing party say they are simply overhauling a corrupt system that obstructs popular will. But critics, both in Poland and abroad, contend they are building one in which the courts are subservient to politicians.

In his zeal to create what he calls a Fourth Republic, free of any vestige of communist rule, and vest the state with ever greater power, the party’s leader, Jaroslaw Kaczynski, has also set the country on a collision course with the EU. The bloc views the changes as a threat to the rule of law and the Western values at the heart of the treaty binding the union of countries.

But the EU’s failure to curb Hungary’s drift toward authoritarianism has emboldened other leaders in the region, where right-wing nationalism and populism are on the rise. Right-wing governments have taken power recently in Austria and Italy, while German Chancellor Angela Merkel, a guardian of liberal Western values, just agreed to build camps on the country’s borders to process migrants.

Story continues below advertisement

If Poland is not made to pay a high price for its actions, critics and outside legal experts worry, currents unravelling democracy in member states will be further strengthened.

It is far from clear how much more the EU can do. For the first time in its history, it has turned to the so-called nuclear option, invoking Article 7 of its founding treaty. Poland could lose its voting rights as part of that process, although that would require a unanimous vote by the 28 member countries – a highly unlikely result, considering its strong backing from other countries that have moved in an authoritarian direction.

European officials also announced on Monday that a so-called infringement procedure had been started against Poland, which could result in the matter being referred to the European Court of Justice. The court could declare the judicial overhaul unconstitutional, but it cannot stop it.

For now, many of the country’s 10,000 judges remain united in their opposition to the government’s measures. And counterpressures are building in Poland’s vibrant civil society.

Lech Walesa, who led the Solidarity movement that ended communist rule in Poland and then served as president from 1990-95, vowed on Sunday to lead a campaign of civil disobedience if Justice Gersdorf and other judges were removed.

“I am saying a definite ‘enough’ to this,” he wrote on Facebook. “If they raise their paws against the Supreme Court, then I am going to Warsaw.”

Story continues below advertisement

Judges who have spoken out publicly against the purge have reported being threatened, harassed and intimidated.

Waldemar Zurek, a former spokesman for the National Council of the Judiciary and a district court judge in the city of Krakow, has been openly critical of the changes. In response, he says, both he and his family have been subject to intense pressure and abuse, including death threats.

Mr. Zurek said he was dismissed as a spokesman for the courts, threatened with disciplinary sanctions over fabricated allegations and harassed by government agents, including at his home. His financial records were improperly disclosed, he has faced what he calls a trumped-up investigations about a long-ago real estate transaction, and he has gotten scores of threatening e-mails and letters.

“All those who stand in the way of the minister become public enemies,” he said. “They are spat on.”

Justice Gersdorf, whose title is first president of the Supreme Court, said she thought that the mandatory retirement age was set with her in mind. Backed by 63 other judges on the court, who voted last week that she should stay in office, Justice Gersdorf said that she would continue to show up for work.

“I have no intention of resigning, since my term of office is six years,” she said.

Story continues below advertisement

Such defiance is the latest and most high-profile development in a confrontation that has been building for months.

In December, the Venice Commission, which is responsible for monitoring rule of law for the EU, expressed “grave concerns” that the judicial overhaul put “at serious risk the independence of all parts of the Polish judiciary.”

Poland was given until the end of June to make changes that would satisfy those concerns. But no agreement was reached in meetings last week in Luxembourg, and Polish leaders vowed to press ahead.

“In essence, this is the end,” Prime Minister Mateusz Morawiecki said on Thursday after meeting with European leaders. “We do not intend to withdraw from this reform.”

Mr. Kaczynski, the governing party’s leader, has not hidden his intentions.

“In a democracy, the sovereign is the people, their representative in parliament and, in the Polish case, the elected president,” he said in a 2016 speech. “If we are to have a democratic state of law, no state authority, including the Constitutional Tribunal, can disregard legislation.”

Story continues below advertisement

Lacking the two-thirds majority needed in parliament to change the constitution, the party instead took control of the tribunal. After that, the tribunal approved laws, like those restructuring the courts, that critics have called unconstitutional.

The party then gave the Minister of Justice the role of prosecutor-general, which had previously been independent, and it took over the National Council of the Judiciary, which is responsible for appointing judges.

Parliament also created a new disciplinary chamber that the opposition says would be used to attack judges who displeased the party.

“Judges in this disciplinary chamber will be earning 40 per cent more than the justices on the Supreme Court,” Justice Gersdorf said. “It has to be emphasized that this is political bribery.”

One of Poland’s great accomplishments after 1989 was restoring public faith in the courts, she said, but it “will require years of rebuilding” to undo the damage being done to that achievement.

She shrugged off concerns that she might have to pay a high price for her defiance.

“They are not putting people in jail, yet,” she said.