WARSAW, Poland -- The office of Poland's president said Tuesday that he has signed into law one of three contested bills that critics say limit the independence of the judiciary.

President Andrzej Duda announced Monday after days of protests that he would veto two of the bills. His office said early Tuesday he signed the third one, despite demonstrations the previous evening in several cities urging him to block that one, too.

The law allows the justice minister, who is also the prosecutor general, to name the heads of all lower courts.

Critics say it is unconstitutional, but welcomed his rejection of the other bills. One of them would have allowed the justice minister to immediately fire all Supreme Court justices and choose their replacements.

Get Breaking News Delivered to Your Inbox

Duda said the law on the Supreme Court gave excessive powers to the prosecutor general.

The European Union had expressed concern over the package of legislation and threatened to act soon to sanction Poland.

Duda's decision appears to mark the first significant rift in the ruling Law and Justice party since Duda won the presidency on the party's ticket in 2015 and the party won parliamentary elections later that same year.

Until this week Duda had loyally accepted all of the party's program, even other steps denounced by the EU and human rights organizations as attacks on the democratic system of checks and balances.

The party says its program is aimed at removing corrupt officials from state positions.