More than 180 foreign nationals were detained after storming the UN refugee agency in Pretoria, where they had been staging a sit-in protest, the police said on Saturday.
Hundreds of asylum-seekers started camping in front of the UN High Commissioner for Refugees (UNHCR) on October 8, asking to be relocated to another country after a spate of xenophobic violence in September.
Protesters broke into the UNHCR premises on Thursday after they were informed of a court order giving them three days to vacate the site.
"One hundred and eighty two men and one woman were taken into custody by the police at different police stations," said provincial police spokesperson Mathapelo Peters in a statement on Saturday.
They were being held on trespassing charges and were expected to appear in the Pretoria Magistrate's Court on Monday, she added.
The statement said the police used water cannons to disperse the protesters who retaliated with rocks and other objects.
The sit-in was cleared and hundreds of women and children were bused to a repatriation centre on the outskirts of Johannesburg as "temporary accommodation", said Peters.
'Door open' for dialogue
Meanwhile, the South African Human Rights Commission (SAHRC) said it would not press charges against foreigners who attacked an archbishop and several others at a church in Cape Town on Friday.
The foreigners - many of whom also claim to be asylum-seekers - had sought refuge at the church after they were evicted from a similar sit-in protest at a building hosting the UNHCR in Cape Town.
They turned violent after they were told to leave.
"I asked the police not to intervene," SAHRC commissioner Chris Nissen told AFP.
"We want to leave the door open for negotiations and dialogue."
The church was calm on Saturday, with some of the occupants slowly packing their belongings, said an AFP reporter.
Officially, South Africa is home to 268 000 refugees and asylum seekers, according to government figures. They are mainly from Somalia, Ethiopia, Zimbabwe and the Democratic Republic of Congo.
They say they suffer ill treatment and discrimination and want to be given a new life in another country.
South Africa boasts some of the world's most progressive asylum policies, allowing foreigners to apply for refugee status and work during the process.
But rights groups say the application system is flawed and backlogged, leaving many asylum-seekers stuck in limbo for years.
As the continent's most industrialised economy, South Africa is also a magnet for economic migrants - a situation that has stoked resentment among jobless South Africans and fuelled sporadic outbursts of xenophobic violence.