Another 35,000 foreigners, however, remain displaced within South Africa, sheltering at police stations, community centres and churches.
 
Many of South Africa's immigrants had fled crises at home, including Zimbabweans fleeing economic meltdown and Somalis escaping their country's bloody conflict.
 
Some poor South Africans blame the foreigners for sky-high crime rates and accuse them of taking jobs from locals. Recent rises in food and fuel prices pushed those tensions to breaking point.
 
Starting May 11, groups of armed youth began attacking foreigners with sticks and knives in Johannesburg's poor slum areas. The unrest eventually spread to seven of the country's nine province.
 
Humanitarian crisis
 
Aid groups warned on Monday of the new humanitarian crisis the unrest has created by displacing so many people.
 
Muriel Cornelius, programme coordinator for South Africa for aid group Medecins Sans Frontieres (MSF), said: "The situation is about to get worse. People have still not received aid and they're not even under tents."
 
The government of Thabo Mbeki, South Africa's president, is now facing a backlash after being accused of failing to spot a rising tide of xenophobia and reacting slowly and ineffectively to the first attacks more than two weeks ago.
 
Mbeki has branded the anti-immigrant violence an "absolute disgrace".
 
Warning of a return to the country's violent past in its struggle against apartheid, the South African president said in a televised address on Sunday that the unrest had damaged the image of the country.
 
He said: "Never since the birth of our democracy have we witnessed such callousness. We must view the events of the past two weeks as an absolute disgrace."
 
Police have arrested more than 500 people in connection with the attacks.