Immigrants clutching belongings sat alongside the road or sought refuge at a local police station and local radio reported crowds of people at community centres and police stations who were seeking protection.
Veli Nhlapo, a police spokesman, told the South African Broadcasting Corporation (SABC): "At the moment, some of the people have been taken to the city hall as a place of safety, but some of them are still running around and do not know where to go."
Two people were killed and more than two dozen shacks were torched in the Tembisa township near Johannesburg, SABC reported.
There was some confusion over the death toll, with South African media reporting about 20 dead since trouble broke out a week ago in Alexandra township.
Al Jazeera's Kalay Maistry, reporting from a makeshift camp in Alexandra, said the violence had been unexpected.
"The police and everybody in the country was caught off guard by what's happening," she said.
The violence has displaced thousands of foreigners, who are accused by many South Africans of depriving locals of jobs and committing crime.
"All these things are the fault of the Zimbabweans. They should just go," said one South African woman whose shack was flattened in the violence at Reiger Park.
The bulk of the immigrants to South Africa in recent years have come from Zimbabwe, fleeing an economic crisis in their country.
"South Africans they are good people ... but suddenly now they are acting like animals towards us," one Zimbabwean who who suffered in the violence told Al Jazeera.
The Human Rights Commission accused the government of failing to take the swelling threat of xenophobia seriously.
Tseliso Thipanyane, the commission's chief executive, told public radio: "We got involved in these issues around 1999 when we heard of two foreigners being thrown from a train in Pretoria. We began the 'roll back xenophobia' campaign.
"There has been poor leadership in this country as far as these issues are concerned."
Thabo Mbeki, the president, and Jacob Zuma, the leader of the ruling African National Congress, have both strongly condemned the attacks.