Anti-government protests broke out late Tuesday in Warsaw and several other Polish cities in defense of the country’s constitution, judicial independence and the rule of law.

The protests came as a lower retirement age was taking effect for Poland’s Supreme Court justices. The law introduced by the ruling right-wing party is forcing the chief justice and as many as one-third of the court’s sitting judges to step down.

 Thousands of people gathered in front of the Supreme Court building in Warsaw, where they held candles, sang the national anthem and shouted “Free courts!” and “Down with dictatorship!”

There were also protests in Krakow, Lodz, Katowice, Wroclaw and other cities. In Gdansk, the cradle of the anti-communist Solidarity movement of the 1980s, legendary democracy leader Lech Walesa denounced Poland’s current government, saying it is even more “perfidious” than the communists he helped topple. 

The protests come as Supreme Court First President Malgorzata Gersdorf is being forced to resign under the legislation that lowers the mandatory retirement age for justices from 70 to 65, a change that could force one in the court’s every three judges out. 

Gersdorf, 65, vowed to remain on the court, in line with the constitution, and said she planned to show up for work as usual Wednesday. 

“My term as the Supreme Court head is being brutally cut, even though it is written into the constitution,” Gersdorf told law students during a lecture. “We can speak of a crisis of the rule of law in Poland, of a lack of respect for the constitution.”

Pawel Mucha, an aide to Polish President Andrzej Duda who co-authored the new law, said Gersdorf has no choice but to retire even though she says her term runs until 2020 under the country’s constitution.

In a surprise move, Mucha announced that the temporary acting head of the court will be another of its judges, Jozef Iwulski, who is 66.

The Supreme Court shake-up represents the culmination of a comprehensive overhaul of Poland’s justice system that gives the ruling party new powers over the courts. 

The changes began after the Law and Justice party came to power in 2015 and have expanded gradually. The Constitutional Tribunal, the court that determines if legislation passes legal muster, was the first put under the party’s control.

The Supreme Court is the highest court of appeal for criminal and civil cases in Poland. Its justices also rule on the validity of elections. 

European Union officials and international human rights groups have expressed alarm, alleging the moves represent an erosion of judicial independence that violates Western standards and a reversal for democracy in Poland.

At the protests, people expressed fears that Law and Justice would use its control of the Supreme Court to falsify elections.

Malgorzata Szuleka, a lawyer with the Helsinki Foundation for Human Rights in Warsaw, said forcing Gersdorf to retire before the end of her term is a “clear violation of the constitution.”

The European Commission, which polices compliance with EU laws, opened an “infringement procedure” Monday over the Supreme Court law. The action is the commission’s second against Poland over rule of law and could lead to further legal action and fines.

The government insists it is improving Poland’s justice system, saying it was inefficient and controlled by an untouchable “caste” of judges. It argues that putting judges under the control of the legislative and executive branches will makes the courts answerable to the voters, and thus more democratic. 

The lowering of the mandatory retirement age is affecting 27 of the court’s 73 judges. Some of them have asked Duda for extensions of their service. Gersdorf did not, however, arguing that the constitution guaranteed her continued tenure.