JOHANNESBURG, South Africa (CNN) -- South African President Thabo Mbeki has approved the deployment of the army to help stop attacks on foreigners that have claimed at least 22 lives, his office announced Wednesday.
A woman tries to put out a fire at a shack on the outskirts of Johannesburg.
Along with the deaths, the attacks have displaced an estimated 13,000 people, local Red Cross officials have said.
Many of the victims are Zimbabweans and others from neighboring countries who have fled repression and dire economic circumstances in their homelands.
The violence began about a week ago in Johannesburg's Alexandra Township, police said, and has been concentrated in the city's poorest areas.
Some say the attacks stem from a long-standing feeling among local South Africans that the number of immigrants allowed to stream into the country results in shortages of jobs and essential needs.
One local man reiterated that sentiment in an interview with CNN this week.
"Most of them just have to go back to their country and leave us in peace," said Diamond Minnaar. "That is the only solution. Or they are just going to get killed. Look at how many shacks have burnt down."
The attacks and looting drew condemnation from South African officials and other African leaders before Mbeki approved the military response.
On Monday, the Nelson Mandela Foundation issued a statement condemning the "senseless violence."
According to South Africa's latest census the country has about 45 million people. The South African Department of Human Affairs estimates that more than 4 million people reside in South Africa illegally, but that figure is based on a 10-year-old study and some feel the number of immigrants in South Africa is much higher.
Some say that millions have recently fled to South Africa from Zimbabwe because of violence there since the county's stalled election. A presidential run-off between long-time leader President Robert Mugabe and his opposition challenger, Morgan Tsvangirai, is scheduled for June 27 -- three months after the initial vote.
Zimbabwe also is in the midst of an economic collapse, with nearly 80 percent unemployment.
The stream of refugees means large numbers of people are competing for scarce resources, some say, and aggravates South Africa's own job problems. Unemployment was 23 percent in 2007, according to the latest government study, released in March.
"It's as if we need to protect our resources," said Sipho Seepe, a professor. "When we talk about a better life for all it was meant for us, not for other people."
CNN's Robyn Curnow contributed to this report