The measure had forced 20 of the country's 72 top court judges to leave the bench earlier than planned.
"Poland has infringed EU law," the court wrote in its decision, noting that the measure that came into force last year "undermines the principle of the irremovability of judges, that principle being essential to their independence."
The law was put forward by Poland's ruling Law and Justice (PiS) party in 2017, claiming that getting rid of many of the older judges would modernize the court and root out corruption. Critics, however, argued that it was an attempt by the nationalist PiS to get rid of left-leaning judges and replace them with a more conservative group that would be less critical of the government.
The move prompted massive protests across Poland, both against and in support of the government.
Poland backtracks amid EU pressureAfter coming into power in July 2018, the law was immediately challenged by the European Commission. The ECJ ruled that Poland had to suspend the measure until the case was decided.
Warsaw has since scrapped the law. President Andrzej Duda signed a law in December reinstating the judges who had been forced into early retirement.
Since the PiS became Poland's ruling party in 2015, it has frequently been at odds with Brussels over a series of reforms that the EU has argued violate its regulations, including a controversial new media law that gave government ministers the power to hire and fire the leaders of state broadcasters.
es/rc (AFP, dpa)
DW sends a daily selection of hard news and quality journalism. Sign up here.