Several thousand gathered to hear Evo Morales speak
Bolivian President Evo Morales has said he will push for all immigrants to have the right to enjoy a legal status.
"When the Spanish and Europeans came to America, our forefathers didn't call them illegal," Mr Morales told a crowd of mainly Latin Americans in Spain.
It is thought some 250,000 Bolivians live in Spain, but only around 100,000 are legally resident.
Mr Morales's trip to Spain comes as he gears up for December's presidential election, which he is expected to win.
Several thousand people, many of them Bolivian, gathered at a bullring in Leganes, on the outskirts of Madrid, to hear Mr Morales speak.
"We are working with the United Nations to reach an agreement so workers, who contribute socially and economically, are no longer considered illegal," Mr Morales said.
Mr Morales is leading the opinion polls ahead of December's vote
"We all have the right to live in any part of the world, respecting the laws of each country."
Spain, which has the highest proportion of immigrants of any EU country, has been hard hit by the recession.
The Spanish government has been offering incentives for Latin American immigrants to return home.
Bolivians at Sunday's event in Leganes said they had experienced difficulties in getting visas and finding work.
"We feel like criminals for not having papers, and we're treated like criminals," Bolivian construction worker Nemecio Vidal told Reuters news agency.
During his speech, Mr Morales also hit out at the presence of the US military in South America, to loud cheers from the crowd.
"In Latin America, where there is a US military base there are military coups," he said.
The US and Colombia are discussing an accord to allow the US military access to several Colombian bases, which both governments say will help the fight drug-trafficking and terrorism.
Campaigning is already under way in Bolivia ahead of the 6 December presidential poll.
Bolivians living abroad are allowed to vote but very few are actually registered and have the right to cast their ballots.