South African police on Wednesday arrested around 100 foreign nationals occupying an office building in Cape Town as part of a sit-in protest against xenophobia, later releasing many of them.
Hundreds of asylum-seekers have been camping at UN refugee agency (UNHCR) offices in South Africa's capital Pretoria and the coastal city of Cape Town since October 8.
The foreign nationals were detained after 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 by an AFP reporter on Wednesday evening. Police were not available for comment.
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.
Mainly from other African nations, the foreigners say they are fed up with being ill-treated and discriminated against.
They have asked the United Nations to relocate them to another country, claiming they no longer feel safe in South Africa after a surge of xenophobic attacks last month.
Protesters banged on pots and plastic bottles, chanting "xenophobia government" and "police xenophobia".
Wednesday's Cape Town sit-in overflowed into the building housing the UN's office, prompting the landlord to apply for their eviction.
In a statement, police said about 100 people had been arrested after "they failed to heed the call to disperse".
Clashes broke out as police fired water guns and stun grenades to break up the crowds.
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.
The country boasts some of the world's most progressive asylum policies, allowing foreigners to apply for refugee status within the country itself and to work during the process.
But the UN has voiced concern over the more than 50,000 pending asylum claims -- the highest in sub-Saharan Africa.
Rights groups say the number of people granted refugee status has remained unchanged for the past decade.
As the continent's most industrialised economy, South Africa is also a magnet for migrants seeking better job prospects.
Seen as competing with locals for work, foreigners are often the first to come under fire when South Africa's chronic unemployment and inequality boils into resentment.
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.