Tens of thousands of foreigners fled the anti-immigrant violence in May
South African authorities have extended until Monday a deadline for the closure of six camps for thousands of foreigners displaced by riots in May.
This is to give the Constitutional Court time to rule on an appeal by human rights groups to keep them open.
The provincial government in Gauteng says it is now safe for the foreigners to return to their homes.
The camps were set up in May after 60 people were killed and thousands displaced by anti-immigrant riots.
Earlier this week, a high court judge rejected the human rights groups' submission which argued the closure would violate the rights of the displaced.
The Constitutional Court had been expected to rule on the last-ditch legal challenge on Friday.
The violence - which caused the worst bloodshed in South Africa since the end of apartheid in 1994 - began in a township north of Johannesburg before spreading to other parts of the country.
Those attacked were blamed for fuelling high unemployment and crime. Twenty-one South Africans, mistaken by gangs for foreigners, were among those killed.
Many of those targeted returned to their home countries after the violence in May, while others returned to South African townships - but more than 2,000 of them are still in the secure camps in Gauteng.
The BBC's Jonah Fisher at Rand airport camp, which houses 1,500 foreign nationals, said police had been waiting outside for the decision of the Constitutional Court.
But the provincial government has now extended its deadline till Monday until after the court ruling.
The authorities say the camps were never intended to be permanent.
A spokesman for Gauteng's provincial government told the BBC that it would guarantee the safety of those returning to their homes.
"They have to leave the shelter because we actually invited them... at a time of need. We think enough has been done to do that," Thabo Masebe said.
"We are also convinced that conditions exist in all the communities in Gauteng for the displaced people to safely return to their places. So, we don't expect anybody to refuse to leave."
But a Zimbabwean man at Rand airport camp said he was worried about returning to the community where he lived.
"It's not safe, they're saying, 'We're going to kill them,'" he told the BBC's Network Africa programme.
Mr Masebe said the Gauteng government had a contingency plan to assist those left stranded on Friday with no place to go.
The remaining camps in other parts of the country that housed some 4,000 displaced people are scheduled to be shut down in the coming weeks.
Last week, the medical charity Medecins Sans Frontieres criticised the South African authorities for not communicating any places for the reintegration of the displaced and not properly engaging in a dialogue with camp residents about their immediate future.