Tens of thousands of Poles have demonstrated in the capital, Warsaw, against the country's populist ruling party, calling for the protection of the rule of law from a series of government steps they deem anti-democratic.

Speakers at Saturday's "Freedom March" alleged that the government under Jaroslaw Kaczynski's right-wing, nationalist Law and Justice (PiS) party has eroded the independence of courts and other institutions to such an extent that Poland would not be accepted into the European Union or NATO today if it did not already belong.

Many protesters were carrying red-and-while Polish flags and blue star-spangled EU flags.

"We will not allow Kaczynski to take us out of Western Europe. Together we will defend freedom," said Jacek Jaskowiak, the mayor of Poznan, a city in western Poland.

READ MORE: How Poland's conservatism is playing home and abroad

The event was organised by the liberal opposition Civic Platform (PO) party, but other opposition parties and the Committee for the Defence of Democracy, a civic organisation, also took part.

PO estimated that 90,000 people took part in the protest. The police put the number at 12,000.

The march was smaller than anti-government demonstrations in May 2016, which were attended by more than 200,000 people.

Protesters are concerned about PiS' consolidation of power since taking office in 2015.

PO liberals accuse Kaczynski's government of using its "good change" policy to push through staff changes that undermine the independence of the Constitutional Court and other public institutions, such as television and radio stations.

The PiS, which swept back into power after almost a decade in opposition partly by playing on fears of an immigration influx, has also come under scrutiny for installing loyalists as directors in state-controlled enterprises.

Kaczynski has said refugees bring "cholera to the Greek islands, dysentery to Vienna, various types of parasites".

President Andrzej Duda, who is close to the ruling PiS party, recently stirred controversy by announcing a constitutional referendum in 2018, which critics fear will hand even more power to the government.

The latest polling shows the PO scoring 31 percent, pulling ahead of the PiS (29 percent) for the first time since the October 2015 election.

'We have democracy'

Kaczynski said on Saturday that the protesters were misguided.

"Freedom exists in Poland and only those who do not perceive reality can question that," he said.

"We have democracy: everyone can have their own opinions, everyone can demonstrate, everyone can vote for whom they want, and everyone can write what they want," Kaczynski said in the city of Szczecin.

Separately, a yearly pro-EU parade called the Schumann Parade also took place in Warsaw on Saturday. Poland has been an EU member since 2004.