The leaders signed a joint declaration against the EU rules
South American heads of state have ended a regional summit with a fierce attack on EU immigration policies.
Venezuelan President Hugo Chavez told the Mercosur meeting in Argentina that Europe had "legalised barbarism".
The EU laws, due to come into force in 2010, could see illegal immigrants held for up to 18 months and face a five-year ban on re-entry if expelled.
The summit also voiced concerns about rising global food prices.
But it was the EU rules passed last month that truly united the South American leaders in anger at the gathering in the northern city of Tucuman, says the BBC's Daniel Schweimler in Argentina.
In a joint declaration, they rejected "every effort to criminalise irregular migration and the adoption of restrictive immigration policies, in particular against the most vulnerable sectors of society, women and children".
The statement also noted "the necessity to fight against racism, discrimination, xenophobia and other forms of intolerance".
It was signed by the seven presidents of Argentina, Bolivia, Brazil, Chile, Paraguay, Uruguay and Venezuela, and ministers from associate Mercosur members Colombia, Ecuador and Peru.
Full members: Brazil, Argentina, Paraguay, Uruguay
Full member pending ratification: Venezuela
Associate members: Chile, Bolivia, Ecuador, Colombia, Peru
Ecuadorean President Rafael Correa called the EU measures "shameful".
Brazil's Luiz Inacio Lula da Silva branded it "outrageous, ignominious".
Bolivian leader Evo Morales said the measures did nothing to combat racism.
Argentine President Cristina Fernandez de Kirchner said the law was inadmissible.
Uruguay's leader Tabare Vazquez said: "Nobody emigrates for fun, they do it out of necessity."
There are hundreds of thousands of South Americans working in EU countries, many of them illegally.
Under the new rules, an illegal immigrant can be detained for a maximum of six months. This period is extendable by a further 12 months under certain conditions if, for example, the immigrant fails to co-operate with the authorities.
The other main issue discussed at the summit was the high price of food.
Brazil's president urged more food production, while Bolivia's leader criticised groups that speculate over food prices.
"They must understand that eating is a human right," said Mr Morales.