The Labour Chamber of the Spanish Supreme Court has ruled that foreign workers who do not have valid work and residence permits are not entitled to receive unemployment benefits.
The court said there is nothing in Spanish or international law that entitles foreigners who do not have the right documentation to claim benefits, even if they have previously been working in Spain.
Some Spanish commentators have said that this decision contradicts a 2003 ruling by the same court, which decided that a Columbian employee who had suffered an accident at work was entitled to claim social security benefits, even though he did not have a work and residence permit.
Spanish attempts to encourage foreign workers to repatriate are proving unsuccessful.
Last year, the government introduced financial incentives for foreign workers to leave Spain, but few have taken up the offer in return for a promise not to return to Spain for at least three years.
Spain currently has one of the highest unemployment rates in Europe, hitting 13.9% in the last quarter of 2008.
The Spanish government expects it to peak at 15.9%, but the European Union has said it could go as high as 19%.