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. The ruling party says not all judges meet professional and ethical standards.

In announcing his decision Monday Duda said the law gave excessive power to the prosecutor general.

“In Poland’s Constitution, in the constitutional tradition, the prosecutor general never had any supervision over the Supreme Court,” Duda said.

A prominent member of the ruling Law and Justice party, which seemed to be taken by surprise by Duda’s veto, said the party was “a little worried” that Duda listened to the protesters.

“We don’t want the street to have influence on the legislative process in Poland,” said Ryszard Terlecki, who is deputy parliament speaker and head of the party’s lawmakers.

Party leader Jaroslaw Kaczynski says the government will not yield to opponents in the “street and abroad.”

The European Union had expressed concern over the package of legislation and threatened to act soon to sanction Poland. A discussion on next steps is to be held Wednesday.

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

Terlecki denied speculation by reporters about a conflict between the party and Duda.

“There is no war at the top,” he said.

Until this week Duda had accepted the entirety 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.

Deputy Justice Minister Patryk Jaki said he was “disappointed” with Duda’s decision.

“It may halt the reform of the judiciary maybe forever,” Jaki said.