WARSAW (Reuters) - Poland’s constitutional court gave its final approval on Thursday to a bill that could be used to ban certain demonstrations and is part of a wider crackdown on opponents by the right-wing government.

The government-sponsored freedom of assembly bill gives officials the power to ban counter-demonstrations that take place within 100 meters of a rally deemed to be of national importance by state authorities, such as historical anniversaries.

Critics have said the new law could be used to restrict unwanted protests by a government that has already been accused by the European Commision of undermining the rule of law and democracy in Poland.

The nationalist-minded Law and Justice (PiS) party has already passed several laws that make it more difficult for the court to challenge new legislation, in moves criticized by the EU and Poland’s western allies.

Under Poland’s current rules on demonstrations, local authorities give precedence to whichever organization filed the first request to stage a rally or protest.

The right-wing PiS faced mass protests last year over its overhaul of the constitutional court and a plan to ban abortion that was later dropped.

Thursday’s ruling obliges President Andrzej Duda, a close ally of PiS, to sign the bill into law. Duda had at first refused and sent it to the Constitutional Tribunal.

PiS-appointed Judge Mariusz Muszynski announced the verdict to an empty chamber via a video feed, after the court had banned media from attending.

“They allow certain socially-important values to be shown and make them a subject of public debate,” he said, referring to rallies deemed to be of national importance.

The opposition, however, denounced the ruling as illegal, citing concerns over the composition of the court.

PiS-appointed judges had earlier excluded from ruling on the case three others who had been chosen by the previous parliament.

The three were excluded following a complaint by Justice Minister and Prosecutor General Zbigniew Ziobro. They had been expected to vote against passing the bill.

Another judge appointed by the previous parliament, Stanislaw Biernat, was sent on compulsory leave by the PiS-appointed head of the tribunal, Julia Przylebska, who argued Biernat had amassed a large number of unused days off.

Only eleven out of 15 judges, therefore, ruled on the bill, which passed with the backing of seven, who were all PiS-appointees.

Three of the four judges who opposed the bill were appointed by the previous parliament.

“Today’s proceedings are a violation of the right to a fair trial,” said Michal Szczerba, a lawmaker of the largest opposition party Civic Platform (PO).

Przylebska said at a news conference that the composition of judges was legal.