South Africa’s high court has temporarily prevented the deportation of more than 300 undocumented migrants.
Rights activists have criticised the arrests of more than 700 suspected illegal migrants following recent deadly xenophobic violence.
Police say they made the arrests during crime prevention operations.
The authorities have been under pressure to both bring an end to the attacks on foreigners and to introduce tighter immigration controls.
The African migrants detained at the Lindela repatriation centre, 25km (15 miles) west of Johannesburg, were due to be deported on Wednesday, reports the BBC’s Nomsa Maseko.
They had been arrested over the past few weeks during night time raids in and around Johannesburg.
But their deportation has been halted for at least two weeks after the organisation Lawyers for Human Rights went to the Johannesburg High Court to prevent it from taking place.
The lawyers have also been given permission to consult with their clients after being barred from doing so by the government.
This will give the lawyers time to get a list of names of those who have been arrested, and check if they are in the country as asylum seekers.
The raids come after a wave of xenophobic attacks in April which affected major cities in South Africa.