BRUSSELS (Reuters) - Poland’s new rules that lower the retirement age for judges, introduced in 2017, break European Union law, an advocate general for the EU’s top court said in an opinion on Thursday in a blow to Poland’s euro-skeptic government.

Poland’s ruling Law and Justice (PiS) party pushed through a range of powers after coming to power in 2015 that rights groups and the European Commission said threatened the rule of law and increased the government’s control over Polish courts.

The PiS originally argued the changes were needed to improve the efficiency of the courts and rid the country of a residue of Communism.

“The contested measures violate the prohibition of discrimination on grounds of sex and the principles of irremovability of judges and of judicial independence,” Advocate General Evgeni Tanchev said in a statement.

The EU Court of Justice is not bound by its adviser’s opinion but usually follows it in the majority of cases.

In 2017, Poland lowered the retirement age for judges of the common law courts, public prosecutors, and judges of the Supreme Court to 60 for women and 65 for men from 67 for both.

The European Commission, which is the guardian of EU treaties, sued Poland over the changes, which allowed the Polish government to force out some judges and replace them with its own appointees, chosen by the National Council of the Judiciary, which had also earlier been dominated by the ruling party.

The court adviser said that the lowering of the retirement age had to be accompanied by safeguards to make sure it does not mean the judge is in fact being removed and the law of 2017 did not guarantee that.

The 2017 law also left it up to the justice minister, a member of the ruling party and the government, to extend the period of a judge’s active service, the advocate general said, making the judiciary dependent on the executive.

“This package is inconsistent with the objective element of impartiality as protected under the case law of the European Court of Human Rights,” the statement said.

“Advocate General Tanchev concludes that by lowering the age of retirement of judges of the common law courts, and by vesting the Minister of Justice with the discretion to extend the active period of such judges, Poland has breached its obligations under EU law,” the statement said.