Poland's parliament passed a bill on Friday that would grant the government powers to punish judges despite criticism that it could imperil the independence of the judiciary.

The bill has been widely criticized by the European Union and the United Nations, with threats being made that, if it becomes law, Poland may lose its voting rights in the EU.

The bill was approved by Poland's lower house and will now face a vote in the Senate before being signed off by the president, who is in favor of it.

Read more: What are Poland's controversial judicial reforms?

If made into law, it will give the government power to fire and control judges. The law would directly violate EU legislation on the judicial system.

The bill could "result in judges being dismissed if they question the government's judicial reform" and infringe on the judges' freedoms of expression and association, UN Human Rights Office spokesman Rupert Colville said on Thursday.

Friday's vote was held after two days of emotional debate, with government supporters defending it as a way of bringing order to what they argue is a "chaotic" justice system and opposition lawmakers saying it threatens democracy.

The legislation was slightly amended after protesters took to the streets, but in the latest version judges could still lose their jobs at the government's whim.

The EU formally called on Poland to suspend the legislation earlier on Friday. European Commission Vice-President for Transparency and Values Vera Jourava tweeted that she did not want Polish lawmakers to advance the measure.

The bill passed with 233 lawmakers voting in favor and 205 against, after it was hastily presented following criticism from the EU.

Watch video 05:38 Share The fall of the Iron Curtain - Poland Send Facebook google+ Whatsapp Tumblr linkedin stumble Digg reddit Newsvine Permalink https://p.dw.com/p/3MccN The fall of the Iron Curtain - Poland

Each evening at 1830 UTC, DW's editors send out a selection of the day's hard news and quality feature journalism. You can sign up to receive it directly here.

ed/cw (dpa, AP, AFP)