Several thousand demonstrators marched through central Johannesburg on Thursday to protest against a spate of deadly attacks on immigrants, after further raids by the authorities on suspected gang hideouts.
Watched by police, crowds sang songs denouncing xenophobia and carried banners that read "We are all Africans" as migrant workers crowded balconies, shouting their support.
"This march sends an important message to the world, to Africans," David Makhura, premier of Gauteng province of which Johannesburg is the capital, told the demonstrators.
"We are going to defeat xenophobia like we defeated apartheid. We are here to make sure that South Africa is a country of peace for all."
Soldiers were deployed in Johannesburg this week to aid police in operations against hostels housing South African men who are accused of targeting migrants from Zimbabwe, Malawi, Mozambique and other African countries.
At least seven people have been killed in three weeks of unrest that have revived memories of xenophobic bloodshed in 2008, when 62 people were killed.
"I am here to make a stand, to say 'Not in my name'," Zain Mayet, 20, one of the marchers, told AFP.
"Keeping quiet makes me as guilty as those who are committing violence. We are here to demonstrate that not everyone in South Africa is a criminal who attacks foreign nationals."
UN chief Ban Ki-moon condemned the violence and called for "all efforts" to be made to avoid future attacks.
"He welcomes the public expressions of the many South Africans who have been calling for peaceful coexistence and harmony with foreign nationals," Ban's spokesman said in a statement.
Police search local residents during a raid on a hostel in Johannesburg's Alexandra township April 23, 2015. (Reuters)
Forced to flee
Two people were arrested late Wednesday when police, backed by soldiers, stormed a workers' hostel in the city's crowded Alexandra township.
In total, over 300 people have been detained.
The unrest erupted in the port city of Durban about three weeks ago and later spread to Johannesburg, the economic capital.
Many immigrants have been forced to flee their homes and abandon their small shops as marauding mobs hunted down foreigners at night.
"Over 5,000 people from Malawi, Zimbabwe, Mozambique, Democratic Republic of Congo and Burundi still seek refuge in displacement camps," Medecins Sans Frontieres (MSF - Doctors Without Borders) said in a statement.
"Injured Malawian and Zimbabwean men told medics that they are too afraid to openly seek medical treatment for their wounds and fractures for fear of further attack."
More than 20 years since the end of apartheid, many South Africans believe the lack of opportunities for young blacks and a severe jobs shortage has led to deep frustration.
One Mozambican man was stabbed to death in Alexandra township last Saturday in scenes that provoked widespread outrage after the killing was captured in graphic newspaper photographs.
Alexandra, where Nelson Mandela lived as a young man, is one of the most troubled parts of Johannesburg and is located next to the upmarket business district of Sandton.
President Jacob Zuma has pledged to tackle anti-migrant sentiment in South Africa and to address deep-rooted problems behind the attacks.
"South Africans are not xenophobic," he said Wednesday. "If we don't deal with the underlying issues, it will come back."
Zuma gave few details of government plans, but said the violence was driven by "criminal elements" as well as friction between foreigners and locals.
Regional relations have been strained by the attacks, with Zimbabwe, Malawi and Mozambique organising for some worried citizens to return home.
Neighbouring Mozambique said more than 2,000 citizens had fled the violence.
Five buses also arrived back in Zimbabwe on Wednesday.