WARSAW, Poland (AP) — In Poland's most-watched political satire, the president is mocked as a marginal and pitiful figure. He waits endlessly outside the office of the country's powerful ruling party chairman, who can never be bothered to see him, the chairman's secretary not even aware of the president's position or real name.

The writers of the hit series "The Chairman's Ear" will now have to change their script.

This week President Andrzej Duda took the country by surprise by vetoing two of three contentious laws seen as an attack on an independent judiciary after days of mass nationwide protests.

It was Duda's first substantial independent act in nearly two years of approving every key law the ruling Law and Justice party has passed, even moves seen as violations of the constitution in the young democracy.

Hand-picked as the party's candidate in 2015 elections by party leader Jaroslaw Kaczynski, Duda has been commonly described by critics as a "puppet" or a "notary" who merely rubber-stamps the party's populist program. A feature of anti-government street protests in recent months has been an effigy of Kaczynski controlling two puppets, Duda and Prime Minister Beata Szydlo.

"It took Andrzej Duda two years to understand that being Poland's president does not mean the passive signing of legislation that the ruling party puts on his desk," Robert Felus, editor of the Fakt daily, wrote Tuesday.

Duda's decision to veto two bills gave hope to the many thousands of Poles who have been protesting for more than a week, afraid the overhaul of the court system spelled an irreversible step toward authoritarianism. They have rejoiced at the way their protests stopped two of the bills, despite disappointment he signed the third on Tuesday.

Law and Justice says that Poland's justice system is corrupt and inefficient and is calling for deep changes, including a purge of many judges. It is a view that is shared by many Poles, including President Duda.

Political observers in Poland believe Duda's independent decision however signals a rift in the ranks of the ruling party and raises Duda's chances if he chooses to run for second term in 2020 by giving him an independent profile.

Duda said he believed the bills he rejected would not increase a sense of security or justice in society, and said he was taking full responsibility for his decision.

There are hints he finally revolted against being taken for granted by the party leadership.

In explaining his decision he voiced irritation that he had not been consulted by the party lawmakers who drew up the legislation.

One of the bills he chose to veto would have changed the functioning of the Supreme Court, calling for the immediate dismissal of all its judges and giving power to replace them to the justice minister. Following an earlier contentious change, the justice minister is now also the prosecutor general.

"We have no tradition of the prosecutor general being able to interfere in the work of the Supreme Court," he said.

One of the Supreme Court roles is to confirm election results, and critics feared the ruling party would be tempted to abuse that new power.

Duda was just 43 when he was elected in 2015. A little-known European Parliament lawmaker for Law and Justice at the time, Duda was picked by Kaczynski because he had been a loyal aide to his late twin brother, Lech Kaczynski, the president who perished in a plane crash in Russia in 2010.

A lawyer by education, Duda took steps early in his term to bolster the party which were seen as violations of the law. First, he pardoned a ruling party member, Mariusz Kaminski, who had been convicted of abuse of power and whose case was still awaiting appeal. The decision was described as a violation of the constitution by some legal experts.

He later drew stronger condemnation by helping Law and Justice take political control of a key court, the Constitutional Tribunal, by changing its rules and some of its members. Getting the court under party control removed a key check on its power, allowing it to pass laws with little risk of them getting struck down as unconstitutional.

The joke from the political satire about the humiliations suffered by the president featured in the protests of the last days. In the show, the party chief's secretary always calls the waiting president "Adrian" instead of by his real name, Andrzej.

"Adrian, become Andrzej!" protesters have shouted in urging him to finally emerge as his own person, even in defiance of his powerful patron.

Some now say he has.

Jaroslaw Kurski, deputy editor of the liberal Gazeta Wyborcza daily, wrote Tuesday that Duda "has many times violated the constitution that he had sworn to protect and has led to the destruction of the Constitutional Tribunal."

"But we must admit, he has refused to take part in the total destruction and submission of the justice system to one party," Kurski said. "President Duda has not stopped being his party's son, but he has just cut the umbilical cord."