The homes of migrants in South African township were set ablaze by residents who believe the foreigners have been illegally working in disused local mines.
Outrage spread in the country after a large group of miners were accused of the gang rape of eight women last week.
The police detained dozens of people are being held by police in connection with the assault but none have been charged with rape.
Poverty has been one of the drivers of xenophobic attacks, in recent years.
Some believe – whether rightly or wrongly – that foreigners are the cause of many of their difficulties.
People in Kagiso say the foreign miners – known locally as Zama Zamas – are responsible for crime in the area. The sexual assaults last week in nearby Krugersdorp enflamed tensions and residents called for a demonstration.
Explaining the motivation behind the protest, one resident told the BBC: “I’m scared to go to the shops. Our police are not doing anything.”
“Let them stop doing what they are doing,” another woman said, blaming the migrants for violent attacks.
On Thursday morning, police, both on the ground and in helicopters, fired stun grenades and rubber bullets to disperse angry mobs who were chasing the miners.
People armed with garden tools forced them to seek safety in old underground mine ventilation shafts.
A journalist from national TV station eNCA described seeing naked men being marched through the area and then beaten.
The police detained 22 men who had been targets of the violence in a move that may have been to prevent them being lynched.
There are reports that one person has been found dead, but it is unclear if the death is related to the protest.
Rocks, rubble and burning tyres have been used to blockade major roads in the township.
People in Kagiso are now saying they fear reprisal attacks at night time.
Last week, women aged between 19 and 35, who were part of a group reportedly filming a music video near a disused mine, were attacked and raped by dozens of people.
President Cyril Ramaphosa described the attack on the women as the “ugly and dark side of society”.
The high levels of sexual violence in the country have led to frequent calls for more to be done to prosecute the perpetrators.
At least 130 men have been detained following the assault but many are facing charges relating to their immigration status as well as the illegal possession of firearms and explosives.
The police say they are waiting for DNA tests to be concluded before charging people with rape.
The miners – most of whom come from neighbouring countries – work in unsafe and unregulated conditions in the abandoned mineshafts that surround Johannesburg. (Source: BBC)