Poland’s constitutional court has ruled that the country does not have to obey orders from the EU’s top court relating to its contested judicial overhaul, escalating a feud between Warsaw and Brussels over the rule of law.

The constitutional court ruling caps a five-year battle over wide-ranging changes carried out by Poland’s conservative-nationalist Law and Justice (PiS) party, which give politicians sweeping powers over the judiciary.

Those changes sparked legal challenges from Brussels, which regards the overhaul as a fundamental threat to judicial independence in the EU’s fifth-biggest state.

One of the changes introduced was a new chamber for disciplining judges, which the Court of Justice of the EU (CJEU) last year ordered Poland to suspend.

The chamber asked Poland’s constitutional court — which critics say has been neutered by the ruling party — to rule on whether such orders were compatible with Poland’s constitution.

On Wednesday, a panel of judges led by Stanislaw Piotrowicz — a former PiS MP and communist-era prosecutor — said the CJEU could not impose such orders, known as interim measures, in relation to Poland’s judicial changes.

During the hearing, Pawel Filipek, a lawyer representing the office of Poland’s ombudsman, warned that a decision that conflicted with EU law would have “far-reaching consequences”, and could ultimately bring Poland’s position in the EU into question.

“The choice would be changing the Polish constitution, causing the [EU] treaties to be changed, or leaving the EU,” he said.

MPs from the ruling coalition led by prime minister Mateusz Morawiecki have long argued that the changes to Poland’s judiciary were needed to overhaul an inefficient system, and that the CJEU had no right to intervene.

“It’s time to treat the CJEU like it deserves. To completely ignore the unlawful actions of politicised ‘judges’,” Janusz Kowalski, a MP from United Poland, one of PiS’s two smaller coalition partners, wrote on Twitter shortly before the ruling.

“Only the constitutional court has the right to adjudicate what in Poland is or is not in accordance with the Polish constitution, which is a law superior to EU law.”

However, critics said the decision was an attempt to give the Polish government ammunition to defend it against criticism of its reforms by the EU. Shortly before the constitutional court delivered its ruling, the CJEU issued a second order for Poland to suspend the disciplinary chamber. The CJEU is also due to rule on Thursday on whether the chamber breaches Poland’s EU treaty obligations.

“[Wednesday’s ruling was] a smokescreen to cover the unsuccessful attempt to reform the Polish legal system, which turned out to be a change of personnel to substitute real judges with people loyal to the party,” said Marcin Matczak, a law professor at Warsaw university.