MADRID — Tens of thousands of Spaniards took to the streets during the weekend to protest austerity budget cuts and commemorate the anniversary on Tuesday of a movement that inspired other groups on Wall Street and across the Western world.

Over all, protesters gathered in about 80 Spanish cities, but again, one of the biggest turnouts was in Puerta del Sol, the Madrid square that almost a year ago became the center of a nationwide, youth-led movement seeking to overhaul Spain’s political parties and other traditional institutions. About 40,000 people gathered in the square on Saturday evening, while a similar number of protesters rallied in a square in Barcelona.

This time, however, the authorities had decreed that protesters would not be allowed to turn Puerta del Sol into an encampment and that any gathering there would have to end by 10 p.m. Instead, to reduce the risk that a standoff could turn more violent, the police waited until 5 a.m. Sunday to clear the square, arresting 18 people. Two police officers were injured during the operation. The protesters — known as the indignants — are vowing to make further attempts to seize control of the square before Tuesday. The movement is known in Spain as 15-M because of its starting date last year.