There were a total of 4,718,864 foreigners registered in Spain as of January 1st, 2015, a 6.1 percent decline over the same period a year ago, according to preliminary figures from the National Statistics Institute.
The biggest falls in percentage terms were among immigrants from Spain's former colonies in Latin America.
The number of Peruvians living in Spain plunged by 21.3 percent to 71,045, the number of Ecuadorians dropped by 19.5 percent to 176,247 while the number of Colombians fell by 17 percent to 150,956.
Romanians and Moroccans are the two largest groups of immigrants in Spain but their numbers shrunk as well last year.
The number of British nationals registered in Spain fell by 6.0 percent to 282,120.
Foreigners have been especially hard-hit by Spain's economic downturn, sparked by the collapse of the labour-intensive property boom in 2008.
The number of foreigners living in Spain ballooned during the boom, jumping from 923,879 in 2000 to 5.2 million in 2011.
Spain returned to growth last year, with an expansion of 1.4 percent. While the unemployment rate has started to fall, it stood at 23.7 percent at the end of 2014, the second highest rate in the eurozone after Greece.
The number of Spaniards in the country increased by 134,231 bringing Spain's total population to 46.6 million.