The trouble broke out during Saturday's huge march through the capital demanding more jobs and more funding for education and social programs.
Tens of thousands of protesters filled Plaza de Neptuno and listened to speakers call for the resignation of the Spanish government.
But the situation deteriorated when some members of the crowd set fire to trash bins near a police stations, which thinkSPAIN said caused officers to fire shots in the air and make several arrests. Furniture was thrown into the streets, causing police to close the area around the square to traffic.
The protest organizers said the fracas was not officially connected to the rally.