The miners rallied noisily in central Madrid at the climax of a 44-day protest against a 60 percent cut in coal subsidies, which they say will force mines to close and put many out of work.
Police fired rubber bullets at protesting miners on Wednesday, injuring several people, during a demonstration against slashes in coal subsidies aimed at trimming the budget deficit of the euro zone's fourth largest economy.
Spain is cutting costs and raising taxes in an effort to hit strict European budget targets. Prime Minister Mariano Rajoy on Wednesday outlined a package of measures aimed at saving a further 65 billion euros ($79.66 billion).
The miners, joined by public sector workers and unions, rallied noisily in central Madrid at the climax of a 44-day protest against a 60 percent cut in coal subsidies, which they say will force mines to close and put many out of work.
"We're only asking that they cut 10 percent instead of 60," said Carlos Marcos, 41, who has worked in the mines for more than half his life. "If they don't pay attention to us, we'll be back - with dynamite."
Tens of thousands of protesters, chanting and throwing firecrackers, marched through the capital to the Industry Ministry, where some threw stones, fruit, bottles and firecrackers at waiting riot police.
Police charged at protesters and fired unleashed several rounds of rubber bullets after demonstrators knocked down fences to contain the protest.
Some of the miners on the "black march" had walked 400 km (250 miles) from the north of Spain where mining has been a part of life since the 18th century. Many waved wooden walking sticks.
"We have to take to the streets to fight because the time is coming when we won't have enough to eat," said 38-year-old miner Jose Ramon Pelaz.
Miners from all over Spain travelled in 600 buses to the capital on Tuesday.
They gathered in Madrid's Puerta del Sol, the centre point of Spain and switched on the lights on their helmets in the early hours of Wednesday, and were met by thousands of Spaniards who turned out in sympathy.
The protesters marched down the city's main business strip, Paseo de la Castellana, singing rowdy songs and waving banners with slogans like, "Rajoy, your future is darker than our coal."
Official figures on the number of arrests were not available, but a Reuters witness saw several people detained at the protest.