CAIRO (Reuters) - Egypt’s Supreme Constitutional Court upheld on Saturday a law that effectively bans protests, settling a years-long court battle and protecting the law from further challenges.

The law was passed in 2013 amid persistent demonstrations calling for the reinstatement of Muslim Brotherhood leader Mohamed Mursi after the military overthrew him following mass protests against his rule.

It requires would-be protesters to notify the interior ministry of any public gathering of more than 10 people at least three days in advance, imposes jail sentences of up to five years for those who violate a broad list of protest restrictions, and allows security forces to disperse illegal demonstrations with water cannons, tear gas and birdshot.

The court’s ruling keeps all of these elements of the law intact and there is no further appeal.

Egyptian rights organizations have said the law criminalizes all forms of peaceful assembly and gives the state a free hand to disperse peaceful gatherings by force.

Its strict enforcement has largely succeeded in ending the kind of mass demonstrations that helped unseat two presidents in three years as activists who have held even small, peaceful gatherings were detained.

The ruling means that hundreds of protesters arrested under the law will remain in prison.

“It was a surprise. We were hoping that the constitutional court would come down on the side of rights. There isn’t a court in Egypt that has mercy on the people,” prominent human rights lawyer Gamal Eid told Reuters.

The case was first brought to an administrative court in 2014 when a group of lawyers challenged parts of the law they said violated article 73 of the constitution.

The article allows the “right to organize public meetings, marches, demonstrations and all forms of peaceful protest while not carrying weapons of any type, upon providing notification as regulated by law.”

But the court ruled on Saturday that only article 10, which grants the interior ministry authority to deny protest requests, was unconstitutional.

It upheld three other articles being challenged, including one which requires protesters to submit detailed information on the location and purpose of their gatherings and another stipulating jail sentences and hefty fines for illegal demonstrations, which the law defines broadly.