Updated

Thousands of people protested in Spanish cities on Saturday against a new law that sets hefty fines for offenses such as burning the national flag and demonstrating outside parliament buildings or strategic installations.

The Public Security Law, which was approved last week by parliament, has been heavily criticized by opposition parties and human rights groups as an attempt by the conservative government to muzzle protests over its handling of Spain's financial crisis.

Saturday's largest demonstrations occurred in cities such as Barcelona, Bilbao and Madrid, while smaller ones took place in Almeria, Granada and Valencia. Some protesters wore tape covering their mouths and carried placards calling the measures a "gagging law."

The new law allows fines of up to 30,000 euros ($37,000) for disseminating photographs of police officers that are deemed to endanger them or their operations.

Individuals participating in demonstrations outside parliament buildings or key installations could be fined up to 600,000 euros ($745,000), if they are considered to breach the peace. Those insulting police officers could be fined up 600 euros ($745). Burning a national flag could cost the perpetrator a maximum fine of 30,000 euros.

The protests — which saw demonstrators mingling with large crowds of Christmas shoppers in some cities — ended peacefully. Police in Madrid forced media photographers to produce identity papers.

The demonstrators included groups opposed to forced evictions because the law can levy fines of 30,000 euros for attempting to prevent home repossessions.

Others protested an element of the new law that entitles police in Spain's North African enclaves of Ceuta and Melilla to summarily expel migrants caught trying to enter Europe by storming border fences.