Defying Brussels, Poland's parliament on Friday passed a law punishing judges critical of controversial court reforms, a measure the governing conservatives say is necessary to avoid judicial chaos but that the opposition calls a threat to the rule of law.

The bill was passed on Friday afternoon to cries of “disgrace” from opposition MPs after being rushed through the parliament in a matter of days.

The proposals, tabled by MPs from the ruling Law and Justice party, bans judges from attending protests, criticising the law and prevents judges from referring questions to EU courts, which contravenes European law.

Justifying the bill, the government argued the legislation will bring an end to what it has called “anarchy” in the courts where courts can rule against each other, and judges attack the rules they are supposed to uphold.

But it has raised fears that the Law and Justice government is intent on politicising the judicial system by forcing judges to follow government policy, which could lead to the Central European country’s departure from the EU.