Poland's lawmakers gave their final approval on Thursday to legislation that will allow politicians to fire judges who criticise their decisions, a change that European legal experts warn will undermine judicial independence.

The legislation passed in the lower house of parliament, the Sejm. It goes next to President Andrzej Duda, who has expressed his support for the legislation and is expected to sign it into law.

More:

Proposed by Poland's right-wing governing party, which seeks more control over the judiciary, the law has been condemned by the European Union, the United Nations and other international bodies, as well as by Polish legal experts and Poland's opposition.

They said it violates EU principles and the democratic separation of powers.

Further aggravating the conflict, Poland's Justice Ministry said on Thursday that it would not recognise a resolution by the Supreme Court which said earlier in the day that some of its newest judges were unlawfully appointed, since they were designated by a new judicial body that is considered to be politically controlled by the governing Law and Justice (PiS) party.

The bill about firing judges was rejected by the Senate last week. The lower house of Poland's parliament, which is controlled by PiS, as expected, gave its final approval in Thursday's vote.

The party has argued the law is needed to prevent "anarchy" among judges, some of whom are critical of the party's policies.

The law would prohibit judges from engaging in any public activities that could be seen as politically motivated.

It curbs the right of judges to form independent judicial bodies and requires them to declare all group affiliations, including any political affiliation from Poland's pre-1989 communist era.

The legislation also bans judges from evaluating or criticising new judicial appointments or powers of state authorities. The punishment for non-compliance ranges from fines to dismissal.

The law is part of changes the governing party has made to the judiciary since it came to power in 2015.

PiS argues the judicial system needs to be made more efficient. Critics agree that improvement is needed but say the changes amount to putting judges under political control.