Polish President Andrzej Duda says he will veto controversial judiciary reform legislation that has sparked large protests and drawn warnings from the European Union.

Duda said on July 24 that would veto two of three bills that opponents fear would erode the division of powers in the EU country and give the ruling Law and Justice party (PiS) too much influence over the courts.

"I have decided that I will send [the bill] back to [the] Sejm (lower house of parliament), which means I will veto the bill, on the Supreme Court, as well as the one about the National Council of the Judiciary," Duda said.

Before the reforms became law, they required the approval of the Duda.

"As president, I don't feel this law would strengthen a sense of justice," Duda said in a statement broadcast on national television.

The Supreme Court bill would have given the justice minister, who is also the prosecutor-general, power to appoint judges.

Duda spoke ahead of planned discussions with top judiciary officials that were aimed at resolving the dispute over the reform bills, which were initiated by PiS and passed by the Senate.

Duda is closely aligned with the PiS and has backed its agenda since he became president in 2015.

The PiS has rejected claims that the reforms were a move toward authoritarian rule.

The European Commission had warned that it could suspend Poland's voting rights if it went ahead with the changes.

German Justice Minister Heiko Maas on July 23 told the German newspaper Bild Am Sonntag that "the independence of the judiciary is in danger in Poland."

Tens of thousands of protesters have demonstrated across Poland since July 19 to oppose the legislation and urge Duda to veto it.

In the capital, Warsaw, demonstrators on July 23 rallied in front of the presidential palace, waving Polish and European Union flags and signs and shouting, "We want a veto!" "Free court!" "Freedom, equality, democracy!" and “Free Poland!"

Rallies against the legislation also took place in Krakow, Wroclaw, and other Polish cities. Polish supporters held smaller rallies in Paris, Brussels, London, and other European cities as well.