Catalan police in helmets moved in after about 50 protesters sat down on the street to block municipal cleaning trucks leaving Plaza de Cataluna square after having dismantled the encampment.
Police were shown on national television dragging protesters on the ground and swiping at activists with truncheons. An AFP reporter at the scene sawrubber bullets fired.
The protest blockade broke up within minutes and cleaning crews carried on the work under police surveillance. Hundreds of demonstrators looked on, sitting on the ground in the square.
Five people were taken to hospital, mostly for multiple bruises, said a Catalan emergency medical services spokeswoman.
A total 43 people including one police officer were treated, mostly for light injuries including psychological shock.
The police action was the first attempt to clear demonstrators from a nationwide movement that began May 15 and grew in city squares across the country.
Police said they had to clear the encampment in case Barcelona beatsManchester United in the Champions League football finals in Wembley on Saturday, sparking celebrations in the square.
"Once the cleaning is finished they can go back but without the tents, knives and potentially dangerous objects," a police spokeswoman had explained earlier.
Activists vowed to return.
"They are making us leave because of the match but we will come back again here or somewhere else because our match is more important," said Albert Bonet, 42-year-old artist who is part of the protest.
The demonstrators are known variously as "the indignant", "M-15" after the birth date of their movement, and "Spanish Revolution".
Mostly young, they have gathered in city squares across Spain in peaceful protests to decry mainstream political parties, soaring unemployment, corruption and welfare cuts.
At the vanguard of the rallies in Madrid, protesters remained camped in the central square Puerta del Sol but in smaller numbers than at the peak on the eve of Spain's May 22 general elections.