Dozens of foreign nationals were arrested in the Cape Town CBD in a standoff with the police.
They told eNCA that seven children are missing.
The refugees want to be repatriated to their home countries or moved elsewhere after a spate of deadly riots and attacks in September, which killed at least 10 people and left many foreigners afraid to live in the country.
IN PICTURES: Foreign nationals want out of SA
Clashes broke out when the protesters refused to be evicted from the Waldorf Arcade, a 12-storey office block in Cape Town's central business district.
Large groups of the refugees were seen walking out of the police station on Wednesday evening.
Singing and crying, they carried one of their fellow detained community leaders on their shoulders to the nearby Central Methodist mission.
The church, where many of those released will take shelter, called on the community to help.
The SAPS said in a statement they moved in to evict around 300 people from the area in accordance with a court order.
"About one hundred people have been arrested after they failed to heed the call to disperse," the statement said, adding that the UNHCR had tried to resolve the impasse without success.
The UN called on the protesters to "respect the laws" and "return peacefully to their residences".
South Africa is home to 268,000 refugees and asylum seekers, according to government statistics. They are mainly from Somalia, Ethiopia, Zimbabwe and DR Congo.
Xenophobic violence left at least 62 dead in 2008. Seven people were killed in 2015 and 12 died in the latest spate of attacks this year -- most of them, South African. The incidents occurred mainly in the Johannesburg area.
- Additional reporting Reuters