JOHANNESBURG, South Africa (CNN) -- South African President Thabo Mbeki called the recent xenophobic attacks in his country a "disgrace" Sunday and warned that the attackers would be jailed.
Residents take to the streets of Johannesburg on Saturday to protest violence against foreigners.
In a televised address, Mbeki spoke about the attacks on foreigners that have left at least 50 people dead.
The almost two-week-long spree of violence has been waged by locals who have accused foreigners of stealing jobs and housing opportunities from residents.
"We must never forget that this country's economy was built with the help of migrant laborers, some of whom died in our mines," Mbeki said. "This is a time for unity. Let's speak with one voice. Let us not allow the acts of a few criminal elements [to] take us back."
The violence has caused an estimated 17,000 to 28,000 immigrants in the country to flee their homes, according to police and government sources. Watch them take refuge in a camp »
All the deaths have been in the small province of Gauteng, where the attacks began May 11 in Johannesburg's Alexandra Township. It has since spread to six more provinces: Western Cape, Free State, North West, Limpopo, Kwazulu-Natal and Mpumalanga.
South Africans protesting the violence against foreigners marched in the streets of Johannesburg on Saturday, carrying signs saying, "Stop the Senseless Killing," "Mr. Mbeki, Where are You?" and "Shame on Us."
Mbeki has faced criticism about the handling of the issue. Some say Mbeki hasn't shown enough leadership as evidenced by his waiting until Wednesday, after dozens of deaths, to call out the South African National Defense Force to help police.
The soldiers were deployed to Johannesburg for the first time since apartheid ended in 1994. They and police have been using rubber bullets to disperse rampaging mobs and ward off extensive looting.
More than 400 arrests have been made for crimes ranging from murder to causing a public disturbance, ministry spokesman Hangwani Malaudzi said. Read desperate stories of those fleeing violence
Locals have said that they were angered at the stream of illegal immigrants that have recently entered South Africa from neighboring countries, such as Zimbabwe.
Zimbabwean opposition leader Morgan Tsvangirai, who returned to his country Saturday from Johannesburg, blamed Zimbabwe President Robert Mugabe for the repressive regime and devastated economy that prompted so many citizens to go to South Africa seeking a better life.
CNN's Nkepile Mabuse contributed to this report.