By Peter Biles
BBC Southern Africa correspondent
The clashes pit the poor against one another
Gauteng means "place of gold". The lure of wealth has drawn migrant workers to what is now South Africa's richest province, since gold was first discovered more than 120 years ago.
From a small mining camp in the 1880s, Johannesburg, Gauteng's main metropolis has become one of Africa's great cities.
In recent years, more and more foreigners have poured in.
No-one knows exactly how many live in the crowded inner-city areas and in the squalid informal settlements scattered across Gauteng Province.
The wave of violent attacks on African migrants should have come as little surprise.
There have been simmering tensions between South Africans and foreign nationals for some time, most notably in Cape Town where members of the local Somali community have been victimised over the past couple of years.
There has also been a continuing influx of tens of thousands of Zimbabweans, fleeing the political and economic crisis in their home country.
It is often reported there are up to three million Zimbabwean exiles in South Africa, although the figure is impossible to confirm.
The Zimbabweans are frequently blamed by local people for much of South Africa's crime.
However, the xenophobic anger and violence seen over the past fortnight can be more easily explained by economic factors.
"What's really triggered it, is business competition. South Africans think that foreigners are controlling the taxi industry and the spaza shops (small stores) in the townships", says Loren Landau, Director of the Forced Migration Studies Programme at Wits University in Johannesburg.
Politicians have been quick to point out that many of the African migrants in South Africa have helped to build the wealth of the country.
Political violence in Zimbabwe is one reason for the huge influx of migrants
"Many of them have applied their skills and knowledge in ways that have contributed to Gauteng's economic growth and development and continue to do so", said the Gauteng Provincial Government in a statement released this week.
The Zimbabwean migrants are a prime example.
The country's advanced education system in the early years of independence has created a generation of highly skilled professionals, notably doctors, nurses and teachers.
One problem for the South African government is that it has always been loath to criticise President Robert Mugabe's failed regime.
The South African leader, Thabo Mbeki, refuses to describe Zimbabwe as "a crisis".
As a result, Zimbabwean exiles are, for the most part, treated as economic migrants, rather than given refugee status.
This leaves them fully exposed to the frustration of local South Africans who regard the foreigners as a direct threat.
Lack of solidarity
Members of South Africa's governing African National Congress (ANC) remember their own days in exile during the apartheid era when they found refuge all over the world, but especially in countries such as Zambia, Mozambique and Zimbabwe.
The ANC leaders therefore urge tolerance and respect for foreigners in South Africa today.
But for the younger generation of unemployed, impoverished South Africans, the history of the ANC's exile years means little.
The African migrants in South Africa have therefore become the scapegoats for those on the lowest rungs of the ladder in South African society.
"There is a battle for resources", says Tony Leon, foreign affairs spokesman for the opposition Democratic Alliance.
Thabo Mbeki, seen here with Robert Mugabe, is under fire over the violence
Nelson Mandela's former wife, Winnie Madikizela-Mandela, visited one of the areas affected by attacks on foreigners this week, and apologised on behalf of the ANC.
"It is an explosion caused by lack of delivery. People say the conditions under which they live are conducive to this kind of violence, it's not xenophobic", she said.
The recent violence is the latest challenge for Thabo Mbeki who is fast becoming a lame duck president.
His rival, Jacob Zuma, who secured the leadership of the ANC last December, is looking like the president-in-waiting.
Mr Mbeki is once again under fire from opposition parties and political commentators over a perceived lack of strong leadership.
He has issued two written statements on the xenophobic attacks, but has left senior ministers to tackle the crisis at grassroots level.
The South African government has promised that all foreigners will be fully protected and none will be deported for the time being, regardless of their immigration status.
But many government critics believe the failure to deal decisively with the issue of Zimbabwe has exacerbated the situation.
The Zimbabweans in South Africa are just one component of the foreign migrant population.
However, with reports of increasing political violence in Zimbabwe in advance of a possible run-off in the presidential election, South Africa needs to be braced for a further flood of people across its porous borders.