Government opponents and human rights activists have welcomed a decision by Uganda’s constitutional court to overturn legislation that gave police “supernatural powers” to stop public gatherings and protests.

“It is only in undemocratic and authoritarian regimes that peaceful protests and public gatherings of a political nature are not tolerated,” said Justice Cheborion Barishaki in a ruling on Thursday.

“I wholly reject the notion that the police have supernatural powers to determine that particular public gathering shouldn’t be allowed to happen because it will result in a breach of peace,” he said.

The court’s judges declared section 8 of Uganda’s Public Order Management Act illegal and unconstitutional.

The challenge to the law was brought by three human rights groups, opposition legislators and a retired bishop in December 2013. Similar provisions to those in the act were contained in a previous law that was declared unconstitutional in 2005.

Barishaki said it “defies logic as to why parliament would rush to pass an act of parliament containing provisions that are pari materia [the same] with those that were declared unconstitutional”.

The police used the law to brutally disperse rallies organised by opposition politician Kizza Besigye in the lead-up to the 2016 elections, and more recently to block meetings and concerts by pop star turned politician Bobi Wine.

In a tweet, Besigye said: “Congratulations @nickopiyo & the petitioners for this important court decision nullifying Uganda’s obnoxious POMA Law! Without rule of law however, Uganda police will continue to act with impunity (as it did before this law was made) but without a false cover. Shame on Uganda parliament.”

Dr Livingstone Sewanyana, executive director of the Foundation for Human Rights Initiative, welcomed the ruling, saying it had been “an obstacle to the enjoyment of the right to freedom of expression, association and assembly in Uganda”.

“Granting unfettered powers to police to deny, disperse and block meetings had a chilling effect on the democratic rights of Ugandans, particularly the political opposition, human rights defenders and activists,” he said.

Deprose Muchena, Amnesty International’s director for east and southern Africa, said the law had been used as a tool of repression.

“Under this law police have brutally dispersed spontaneous demonstrations and opposition rallies, while opposition politicians have been beaten up and arrested simply for exercising their rights,” she said, adding that Ugandan lawmakers must now repeal the entire act, which contradicted the constitution, ahead of next year’s presidential elections.

In January, police arrested Wine and fired teargas at his supporters when he tried to hold a rally to mark his 2021 presidential bid.

Since he became a legislator in 2017, Wine has rattled Ugandan authorities, who see him as a threat to President Yoweri Museveni. Museveni has been in power since 1986.

Joel Ssenyonyi, spokesperson for Wine’s People Power Movement, said he was concerned that the ruling would be ignored. “This government is notorious for disregarding court orders,” he said.

“We are hoping this shall not be disregarded, [that] it shall take effect and also that parliament will not run again and create another law like they did previously.”

Sarah Kasande, of the International Centre for Transitional Justice, said the move “will open up space for political activists and human rights defenders to exercise their rights to peacefully assemble, and to debate public policies and advocate for change”.

Sewanyana said: “If people are allowed to speak up, assemble and demonstrate freely, a new political dispensation will be born, giving rise to transformative leadership in the country that is needed more than ever before to counter the new threats once Covid-19 is contained.” Uganda has 18 confirmed cases.