The protest blocked one of the capital's central boulevards opposite the Interior Ministry. On-duty police officers watched as their off-duty colleagues demonstrated by throwing fireworks and chanting slogans.
A demonstrator was injured when a firework he was set to throw exploded in his hand. Many protesters draped themselves in Spanish flags and added to the ear-splitting noise by blowing their police-issued whistles.
Later, police on horseback and with dogs began to arrive at Neptuno fountain next to parliament in preparation for crowd control duties while protesters gathered 2.3 kilometers (1.4 miles) to the west at Plaza de Espana.
The "Surround parliament" protest group had called on people to gather there for a march to the legislature to express their disapproval at spending cuts and tax hikes introduced by Prime Minister Mariano Rajoy's government.
Since being voted to office in general elections in November, Rajoy has hiked taxes, cut spending, including a wage-cut for civil servants, and introduced stinging labor reforms in a bid to persuade investors and international authorities that he can manage Spain's finances without the need for a full-blown bailout.
However, Spain's public finances have been overwhelmed by the cost of rescuing some of its banks and regional governments, many of which have experienced heavy losses following a property sector crash in 2008.
One Spaniard in four is unemployed as the economic crisis tightens its grip. The government is under pressure to seek aid to ease debts while the country sinks into its second recession in three years.
Economic output has contracted for five quarters in a row and Spain's troubled banks have been granted a €100 billion ($130 billion) loan facility by the 17 countries that use Europe's single currency.