South Africa's President Thabo Mbeki has approved the deployment of the army to quell violence against foreigners.
The announcement from his office came after xenophobic attacks spread outside Johannesburg to the city of Durban.
It is the first time troops are being ordered out onto the streets to quell unrest since the end of apartheid.
The violence, which began last week, has left more than 20 people dead and is estimated to have driven 30,000 people from their homes.
The Centre for the Study of Violence and Reconciliation says many of the people were sheltering in mosques and churches around Johannesburg.
There are believed to be between three and five million foreigners living in South Africa, most of them Zimbabweans fleeing poverty and violence at home.
The Durban attack prompted about 700 African migrants to seek refuge in a nearby church while in Cape Town a safety forum has been set up to try to prevent violence.
Police say a group armed with sticks and bottles attacked Nigerians drinking in a tavern overnight.
In Johannesburg, police fired rubber bullets to disperse mobs in one area on Tuesday.
'Political'
There are fears that politicians are exploiting the situation in Durban.
Advertisement
Mobs of South Africans roam townships
"A mob of plus/minus 200 were gathering on the streets carrying bottles and knobkerries (wooden clubs) busy attacking people on the streets," Provincial police spokeswoman Superintendent Phindile Radebe told AFP news agency.
"They attacked one of the taverns there believed to be owned by Nigerians," she said.
KwaZulu-Natal's Community Safety Minister Bheki Cele blamed Zulu nationalist Inkatha Freedom Party members for being behind the Durban violence.
"These are purely criminal activities and they will be dealt with decisively in ensuring that xenophobic attacks are not used as scapegoats for criminals who want to serve their own selfish interests," he said in a statement.
The attacks on foreigners began a week ago in the township of Alexandra, north of Johannesburg, before spreading to the city centre and across the Gauteng region.
Mobs have been roaming townships looking for foreigners, many of whom have sought refuge in police stations, churches and community halls.
Some South Africans say foreigners are taking jobs from locals and contributing to crime.
Earlier, President Mbeki urged South Africans to welcome foreigners.
Bookmark with:
What are these?