CAPE TOWN, South Africa

South Africa is taking stock after two weeks of xenophobic riots. By the latest count, 50 people have been killed and thousands injured. Over 600 rioters have been arrested as the violence spread through all nine of the country's provinces. The images are shocking. Large, well-armed mobs of black people rampage through the townships, even the center of the commercial capital, Johannesburg. The necklace (burning tire) style of killing, so familiar from the civil strife that swept the country in the early 1990s, has made a horrific return. The plight of the foreign Africans has been desperate, with some 30,000 displaced and many of their shops and shacks ransacked or destroyed; unknown thousands have gone back home.

The damage to South Africa's image both within Africa and beyond is very large. Perhaps worst of all, the riots have raised the question of whether the country really made a miraculously peaceful transition from apartheid to multiracial democracy, as so widely trumpeted, 14 years ago. In a ghostly reversal of history, mobs are once more in the streets, and as in apartheid days, the military has been called out to control them. The ruling African National Congress is used to thinking of large, politically mobilized township mobs as masses demanding democracy, and the soldiers out to bring them into submission the instrument of apartheid oppression. Now the roles are reversed, posing some disturbing thoughts about whether one has viewed the past correctly. Certainly the sight of workers attacking workers is a nightmare for the left. The greater fear is that this could all easily spill over into intra-South African tribal conflict.

Nobody knows how many illegal immigrants there are in South Africa. Most estimates suggest that up to four million Zimbabweans have fled here from Robert Mugabe's rule of brutality and enforced poverty. Mozambicans make up the second-largest group. But South Africa's borders are porous and there are also large numbers of people from Malawi, Nigeria, the Democratic Republic of Congo, Somalia and elsewhere in Africa. At a bare minimum there must be five million such illegals, though some think there are twice that number. Xenophobia is not new -- over 30 Somali shopkeepers were murdered in Cape Town in the last two years -- but the country has not witnessed civil strife on anything like this scale before.

The causes are obvious. A Markinor survey earlier this month found that only 42% of South Africans had jobs. Millions are housed in shacks lacking many basic amenities. It is now winter here and at night on the Gold Reef, on which Johannesburg was built, temperatures can fall below freezing, so the homeless can no longer live on the streets. In addition, soaring food prices and shortages of maize, the African staple, have left many hungry. Tempers have frayed and many point to foreigners as a major source of crime.