Image source, Getty ImagesImage caption, Thousands in Poland have demonstrated against controversial reforms, with some brandishing EU flags and copies of Poland's constitution

Poland's top court has rejected the principle of the primacy of EU law over national legislation in certain judicial matters, in a major challenge to the EU's legal framework.

The Constitutional Tribunal said some EU treaty articles were incompatible with Poland's constitution.

It ruled that the Polish constitution took precedence over EU law.

Polish judges, it said, should not use EU law to question the independence of their peers.

The legal challenge was brought by Prime Minister Mateusz Morawiecki.

It was the first time in the history of the 27-strong EU bloc that a leader of a member state had questioned wholesale EU treaties in a constitutional court.

Mr Morawiecki brought the challenge in March after the European Court of Justice (ECJ) ruled that the new system of selecting judges in Poland – introduced in 2018 by the governing coalition – infringed EU law.

Mr Morawiecki wanted to prevent Polish judges from using EU law to question the legitimacy of judges appointed following recent changes to the judiciary.

Those changes have been criticised by the European Commission, the EU's executive body, and many international legal bodies for undermining judicial independence and increasing political control over courts.

Poland's Constitutional Tribunal is now dominated by judges that are sympathetic to the governing Law and Justice party (PiS), some of whom are former party members.

  • Poland broke EU law by cut to judge retirement age
  • Why Poles want more of this man's populist message

The European Commission has already warned it will respond with further legal action against Poland.

Last month, the Commission asked the ECJ to impose daily fines on Poland for its failure to suspend the activities of a new Supreme Court chamber that has the power to sanction judges for the content of their rulings.

Critics say the chamber is being used to punish judges who have been critical of the government's changes to the judiciary.

It's important to note the court's ruling does not take effect until the government publishes it in the Journal of Laws, something it should do within days.

However, it took the government three months to publish the court's controversial ruling virtually banning legal abortion in Poland.

Lurking in the background is Poland's €57bn (£48bn; $66bn) recovery plan, which Brussels has yet to approve.

Negotiations are ongoing and the European Commission has said this legal challenge was delaying approval of the plan.

Could this ruling be hard ball tactics by Warsaw to get the commission to agree the much-needed funds? It's a risky ploy, if it is.

The Commission has already made it clear that it would launch fresh legal action and perhaps delay EU funding to Poland if the court rejected the primacy of EU law in judicial matters.