Poland on Sunday saw several demonstrations against new legislation that critics see as tightening the government's grip on the country's justice system.

The main demonstration, in the capital, Warsaw, started at 3 p.m. local time (1400 UTC) in front the parliament building, which was cordoned off, with a heavy police presence in the area.

The main extra-parliamentary opposition movement, the Committee for the Defense of Democracy (KOD), led the protests under the banner of "This is NOT the end! We will stop the coup." Lawmakers from the main parliamentary party, Civic Platform (PO) also attended, as did the smaller opposition centrist party, Modern and representatives of left-wing groups.

Police told the Onet.pl website that 4,500 people were taking part in the protests in Warsaw. Protest organizers said 10,000 had declared on Facebook they would be attending.

Protesters held placards with slogans such as "Paws off the courts."

Controversial legislation

The protests are the latest in a series of mass anti-government demonstrations against the conservative Law and Justice (PiS) government, which has controlled both houses of parliament since late 2015.

The noisy crowd in Warsaw chanted "We will defend democracy" as well as slogans against ruling party leader, Jaroslaw Kaczynski, who is Poland's most powerful politician.

Legislation was adopted late on Friday by the lower house that gives lawmakers the power to appoint members of the National Council of the Judiciary, the body that enforces ethical guidelines for judges, reviews judicial candidates and seeks opinions on new rules and regulations to ensure they are constitutional. Another bill calls for the retirement of all Supreme Court judges and new appointments to be made by the justice minister.

Both moves have drawn condemnation from EU politicians and from Poland's opposition.

The senate, the upper house of parliament, passed both bills late on Saturday without amendments. They now go to President Andrzej Duda before being signed into law.

Muscular democracy, but still democracy

Kaczynski said on Friday that "radical changes" were needed to "heal" the nation's judiciary.

He said that "far-reaching, radical actions" were required in the judiciary, which he said had not been reformed since communist times. He insisted the changes were in the public interest and fulfilled the party's election campaign promises.

The judiciary has been a key locus of the political struggle in the first 20 months since PiS came to power.

PiS is accused of placing party loyalists on another top court, the Constitutional Tribunal, soon after winning the September 2016 election. The tribunal is the body charged with ruling on whether laws passed by the parliament are in accordance with the constitution.

The party has also been adamant in its promotion of a far more muscular and executive-driven democracy, which critics argue undermines the separation of powers and the rule of law.

PiS supporters argue that the 1989 agreement that led to a gradual - and peaceful - end to communism in Poland didn't go far enough and in effect shielded ex-communists from prosecution after 1989. The judiciary, it contends, is symptomatic of this malaise.

Many argue the party is deliberately attempting to hobble the work of the judiciary and in the meantime run through a series of reforms that strengthen its hold on power, strip away remaining checks and balances - while also simultaneously reorienting the civil service, media, army and education systems.

The state-run main television channel, TVP1 reported the protests as an "attempted putsch" and underlined the low turnout, Poland's largest daily newspaper, Gazeta Wyborcza, reported.