South Africa’s army will be deployed to volatile areas to prevent attacks on foreigners, Defence Minister Nosiviwe Mapisa-Nqakula has said.
The army was intervening because an “emergency” had developed, she said.
Foreign governments have strongly criticised South Africa for failing to protect their nationals.
At least seven people have been killed and 5,000 left homeless since the attacks started about three weeks ago against other Africans and Asians.
“We come in as the last resort. The army will serve as a deterrent,” Ms Mapisa-Nqakula told journalists.
For the latest news, views and analysis see the BBC Africa Live page.
Troops would be deployed to flashpoints in South Africa’s KwaZulu-Natal province and the economic heartland of Gauteng, which includes Johannesburg.
The first deployments were expected to be in Alexandra, a poor township north of Johannesburg.
A Zimbabwean couple were shot and wounded there on Monday night, the minister is quoted by Reuters news agency as saying.
Mozambican Emmanuel Sithole was killed in the township at the weekend.
Some South Africans accuse foreigners of taking their jobs
Four suspects appeared in court on Tuesday over Mr Sithole’s killing, which was caught on camera by a local journalist.
The men were remanded in custody, without being asked to plead.
A crowd protested outside court, demanding justice for Mr Sithole.
Media caption James Oatway, a South African photojournalist, witnessed the killing of a Mozambican man
The army was also deployed during the xenophobic violence in 2008, when at least 63 people were killed, says the BBC’s Nomsa Maseko in Johannesburg.
More than 900 people have been voluntarily repatriated back to their home countries since the violence broke out, officials say.
In Malawi’s capital Lilongwe on Tuesday, at least 2,0000 people protested against the violence.
“South Africa, why kill your fellow blacks?” read one poster.
Malawians showed their anger at a demonstration in Lilongwe The Zulu king has been accused of making anti-foreigners remarks The violence forced some 5,000 people into camps
The protesters chanted slogans against South Africa’s President Jacob Zuma and Zulu King Goodwill Zwelithini, the BBC’s Raphael Tenthani reports from the scene.
They gave Mr Zuma a 48-hour ultimatum to get the monarch to apologise for alleged xenophobic remarks he made last month, or else they would boycott South African goods, he says.
The powerful monarch has denied fuelling xenophobia, saying at a rally on Monday: “If it were true that I said foreigners must go, this country would be up in flames.”
With the unemployment rate at around 25%, many South Africans accuse foreign nationals of taking jobs from locals.
Official data suggests there are about two million foreign nationals in South Africa, but some estimates put the number much higher.