Tens of thousands of Spaniards and Portuguese have protested deep economic pain from austerity measures, with the demonstration in Madrid turning violent for the third time in less than a week.
Thousands of Spaniards had marched close to the parliament building in downtown Madrid peacefully for hours on Saturday.
Police with batons later moved in just before midnight to clear out those who remained late because no permission had been obtained.
Some protesters responded by throwing bottles and rocks. An Associated Press photographer saw police severely beat one protester who was taken away in an ambulance.
Spain's state TV said early on Sunday that two people were hurt and 12 detained near the barricades erected to shield the parliament building.
Television images showed police charging at protesters and hitting them with their batons, but the violence did not appear as severe as a protest on Tuesday when 38 people were arrested and 64 injured.
Earlier, the boisterous crowds let off ear-splitting whistles and yelled "Fire them, fire them!" - referring to the conservative government of Prime Minister Mariano Rajoy, and venting their anger against tax hikes, government spending cuts and the highest unemployment rate among the 17 nations that use the euro currency.
On Friday, Rajoy's administration presented a 2013 draft budget that will cut overall spending by 40 billion euros ($49.85 billion), freezing the salaries of public servants, cutting spending for unemployment benefits and even reducing spending for Spain's royal family next year by four per cent.
Pablo Rodriguez, a 24-year-old student doing a master's degree in agricultural development in Denmark, said the austerity measures and bad economy mean most of his friends in Spain are unemployed or doing work they didn't train for.
He plans to work abroad after graduating and doubts he will put his education to use in Spain until he is at least 35 or 40, if ever.
"I would love to work here, but there is nothing for me here," Rodriguez said.
Madrid authorities put the number of protesters at 4500 - though demonstrators said the crowd was larger.
In neighbouring Portugal, tens of thousands took to the streets of Lisbon on Saturday afternoon to peacefully protest against even deeper austerity cutbacks than Spain has imposed.
Retired banker Antonio Trinidade said the budget cuts Portugal is locked into in return for the nation's 78 billion euro ($A97.21 billion) bailout are making the country's economy the worst he has seen.
His pension has been cut, and he said countless young Portuguese are increasingly heading abroad because they can't make a living at home.
"The young don't have any future, and the country is on the edge of an abyss," he said."I'm getting toward the end of my life, but these people in their 20s or 30s don't have jobs, or a future."