When the South African government called out the army in the midst of a wave of deadly attacks on foreign migrants last month, most people assumed the soldiers would be deployed to protect the foreigners.
Instead the troops – more than 300 of them – have been increasingly deployed to support late-night raids by police hunting for foreigners who lack legal documents. The result: hundreds of foreigners detained without charges and without access to lawyers. Most are vulnerable migrants from some of Africa's poorest countries.
In the latest sweep, an estimated 300 to 400 foreigners were detained during a police and army raid on the Central Methodist Church in downtown Johannesburg, a famed place of shelter for refugees and asylum-seekers for many years.
The detainees have been held in police cells and an immigration custody centre for the past four days, while human-rights lawyers were forced to go to court to seek access to them. Their names and legal status are unknown, and even the exact number of detainees isn't known. Some are believed to be mothers with young children, while others are HIV-positive people who need access to life-saving medicine.
Lawyers say they believe the detainees are being held in harsh conditions. On Tuesday, they won a temporary court order to prevent the deportation of the detainees.
Foreigners were targeted in a similar raid by police and soldiers last week in Durban, the city where the violence had begun last month when a Zulu king called foreigners "lice" and demanded their expulsion.
When the anti-foreigner attacks first erupted, the world was shocked by the images of brutal killings and lootings that forced 5,000 foreigners to flee into camps for shelter. Since then, the violence has diminished but the government is increasingly using its security forces to search for undocumented foreigners, seeing them as the source of the problem.
The police raids are officially called Operation Fiela – based on a word in the Sotho group of languages meaning "to sweep away" or "to remove dirt." In effect, critics say, the government is comparing foreigners to rubbish.
At a time of persistently high unemployment, foreigners have become a popular target. In his speeches after the anti-foreigner attacks began, President Jacob Zuma pleaded with South Africans to stop killing foreigners, but he also tried to placate the attackers by promising a crackdown on what he called "illegal" foreigners.
Rather than reducing the anti-foreigner mood, the police and army raids are legitimizing it, according to Stephen Faulkner, spokesman for a coalition of civil-society groups that support foreign migrants.
Violence against foreigners, especially the looting of thousands of shops owned by foreign migrants in South Africa's impoverished townships, has become an increasingly chronic problem since an early wave of attacks in 2008. More than 350 foreigners have been killed since then. Police have often turned a blind eye to the problem, creating a sense of impunity for the attackers.
While the ruling African National Congress has had an avowed policy of non-racialism since its anti-apartheid days, growing frustrations over economic stagnation and high unemployment have led many politicians to switch to the tactics of "identity politics," including nationalist or traditionalist messages. Racial tensions and an anti-foreigner mood have heightened in recent years.