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 right-wing ruling party is forcing the chief justice and about one-third of the court’s members 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. The change is affecting 27 of the court’s 72 judges.

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 constitution.

In a surprise move, Mucha announced that the temporary acting head of the court will be another of its justices, 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 that the moves represent an erosion of judicial independence that violates Western standards and a reversal for democracy in Poland.

The European Commission, which polices compliance with E.U. 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.