More than 1,000 riot police blocked off access to the Parliament building in the heart of Madrid, forcing most protesters to crowd nearby avenues and shutting down traffic at the height of the evening rush hour.
Police used batons to push back some protesters at the front of the march attended by an estimated 6,000 people as tempers flared, and some demonstrators broke down barricades and threw rocks and bottles toward authorities.
Television images showed officers beating protesters in response, and an Associated Press television producer saw five people dragged away by police and two protesters bloodied. Spanish state TV said at least 28 were injured, including two officers, and that 22 people were detained.
The demonstration, organized with an "Occupy Congress" slogan, drew protesters from all walks of life weary of nine straight months of painful economic austerity measures imposed by Prime Minister Mariano Rajoy and his solid majority of lawmakers. Smaller demonstrations Tuesday attracted hundreds of protesters in Barcelona and Seville.
Angry Madrid marchers who got as close as they could to Parliament, 250 metres (yards) away, yelled "Get out!, Get out! They don't represent us! Fire them!"
"The only solution is that we should put everyone in Parliament out on the street so they know what it's like," said Maria Pilar Lopez, a 60-year-old government secretary.
Lopez and others called for fresh elections, claiming the government's hard-hitting austerity measures are proof that the ruling Popular Party misled voters when it won power last November in a landslide.
While Rajoy has said he has no plans to cut pensions for Spaniards, Lopez fears her retirement age could be raised from 65 to as much as 70. Three of her seven nieces and nephews have been laid off since Rajoy ousted Spain's Socialists, and she said the prospect of them finding jobs "is very bleak."
Spain is struggling in its second recession in three years with unemployment near 25 per cent. The country has introduced austerity measures and economic reforms in a bid to convince its euro partners and investors that it is serious about reducing its bloated deficit to 6.3 per cent of gross domestic product in 2012 and 4.5 per cent next year.
The deficit reached €50.1 billion ($64.8 billion), equivalent to 4.77 per cent of GDP, through August, the government said Tuesday. Secretary of State for the Budget Marta Fernandez Curras said the deficit "is under control."
Spain has been under pressure from investors to apply for European Central Bank assistance in keeping its borrowing costs down. Rajoy has yet to say whether Madrid will apply for the aid, reluctant to ask since such assistance comes with strings attached.
Concerns over the country's public finances were evident earlier Wednesday when the Treasury sold €3.98 billion ($5.14 billion) in short-term debt but at a higher cost. It sold €1.39 billion in three-month bills at an average interest rate of 1.2 per cent, up from 0.95 per cent in the last such auction Aug. 28, and €2.58 billion in six-month bills on a yield of 2.21 per cent, up from 2.03 per cent.
The government is expected to present a new batch of reforms Thursday as it unveils a draft budget for 2013.
A day later, an auditor will release the results of stress tests on those Spanish banks, which have been hit by the collapse of the country's real estate sector. The government will then judge how much of a €100 billion loan it will tap to help bail out the banks. Initial estimates say the banks will need some €60 billion.
Associated Press television producer Iain Sullivan and Associated Press Writer Ciaran Giles contributed from Madrid.