WARSAW, Poland - Poland's president unexpectedly announced Monday that he will veto two bills that would have sharply curtailed the independence of the judiciary, a victory for peaceful protesters who had gathered by candlelight every night for more than a week.

The European Union criticized the bills as assaults on the democratic system of checks and balances and threatened to begin proceedings soon to strip Poland of its voting rights in the 28-member bloc.

President Andrzej Duda “made the right decision,” Guy Verhofstadt, the leader of a liberal alliance in the European Parliament, tweeted. “But the fight for rule of law in Poland goes on - we are with the Polish people!”

The protests mark one of the most significant acts of civic mobilization since the Solidarity protests led by Lech Walesa in the 1980s, with large numbers of young Poles attending rallies daily fearing they might lose a future in a democratic state fully integrated in the West.

Walesa, the Nobel Peace Prize laureate and former president who helped end communism peacefully in 1989, praised Duda for what he called “a difficult and a courageous decision.”

Many Poles fear that a loss of basic democratic rights will change the county into a semi-authoritarian state, mirroring conditions in some other places in Eastern Europe.

“In our hearts and minds we are 100 per cent Europeans,” said Marcin Trzepla, a 26-year-old who attended multiple demonstrations in Warsaw over eight days hoping to stop what he called “a huge step to the East.”

At first Trzepla, who works for an advertising agency, doubted the protests would have any effect, but showed up “so that I can look in the mirror and say I did whatever I could.”

He said he was shocked by Duda's decision to veto the bills given the president's history of loyalty to the ruling Law and Justice party. But he said he would keep on protesting in hopes the president might still block a third bill that would give the prosecutor general, who is also the justice minister, the power to name the heads of lower courts.

Protests continued Monday night in several cities, with people holding up candles and chanting various slogans in defence of the constitution, free courts and democracy.

The bills were presented and passed by lawmakers over a 10-day period with no public consultation after a visit by Donald Trump to Warsaw, where the U.S. leader praised Poland as a defender of Western civilization.

Some critics believe the Law and Justice party, a populist and nationalist group, felt emboldened by Trump's support.

The State Department, however, said Friday that “the Polish government has continued to pursue legislation that appears to undermine judicial independence and weaken the rule of law in Poland.”

Duda's announcement appears to be a heavy setback to the Law and Justice party, led by Jaroslaw Kaczynski, who is widely considered the country's most powerful political figure.

The party's moves over the past two years, including a successful neutralizing of the constitutional court, have raised concerns about rule of law in a country long considered a model of democratic transition.

Duda was hand-picked by Kaczynski as the party's presidential candidate in 2015 and has loyally supported the party's conservative, nationalist agenda until now.

Long derided by critics as little more than a “notary” who rubber-stamps the ruling party's laws, Duda appeared to gain the respect and gratitude of some for his first significant independent act.

His move suggests there could be a growing rift within the ranks of the ruling party. Prime Minister Beata Szydlo said in a televised address in the evening that Duda has delayed much-needed judicial reforms but that the party “will not back down from the path of repairing the state.”

One of the bills Duda intends to veto would have resulted in the immediate dismissal of all Supreme Court justices, giving the justice minister and prosecutor general the power to name replacements.

The second would have changed the functioning of the National Council of the Judiciary, giving lawmakers greater power over court appointments.

Duda said he believes reform is needed to make judges more ethical and the courts more just, but said changes must not happen in an environment where the “state becomes oppressive” and citizens “begin to be afraid of their state.”

He said he consulted many experts before making his decision, including lawyers, sociologists, politicians and even philosophers. But he said the person who influenced him most is a 76-year-old former anti-communist dissident, Zofia Romaszewska.

He recalled Romaszewska telling him: “Mr. President, I lived in a state where the prosecutors general had an unbelievably powerful position and could practically do everything. I would not like to go back to such a state.”

Duda said he would present new draft laws reforming the Supreme Court and the judiciary council within two months after wide consultations with experts.

The head of the Supreme Court, Malgorzata Gersdorf, appeared at a demonstration in Warsaw with other judges on Monday evening, thanking the people for supporting civic rights and the constitution.