Private Nigerian airline Air Peace volunteered to fly people for free back to the commercial capital Lagos on Wednesday.
A flight carrying 189 Nigerians landed in the commercial capital Lagos late Wednesday, with some of those onboard punching the air and singing the national anthem while waving pictures of burnt shops.
"I ran for my life, they would have killed me," Samson Aliyu, a clothes seller who lived in South Africa for two years, told AFP news agency.
"They burnt my shop, everything," he added.
A second flight departs on Thursday or Friday with 640 Nigerians in total fleeing the country.
The repatriation came after riots in Pretoria and Johannesburg killed at least 12 people as 1,000 foreign-owned businesses were targeted. The nationalities of those killed have not been announced but Nigerians, Ethiopians, Congolese, and Zimbabweans were attacked, according to local media.
The violence sparked an international outcry and calls for a boycott of South Africa.
Pastor Ugo Ofoegbu has lived in South Africa for close to two decades. He sent his wife and three children back to Nigeria.
"My family is not safe here," Ofoegbu told Al Jazeera.
Precious Oluchi Mbabie, a 35-year-old Nigerian woman who works as a fashion designer and seamstress in a Johannesburg suburb, boarded the flight with her three children, leaving her husband behind.
"We agreed that it is better I go back home with the children," said Mbabie.
She and her family live in Rosettenville, one of the first areas to be affected by the violence.
"Where we are staying is very dangerous because of xenophobia," she said. "They say they don't want any foreigners there."
Reprisal attacks in Nigeria last week forced South African business to shut down, while the South African embassy in Lagos temporarily closed its doors over safety concerns.
Not just Nigerians
More than 700 people from other countries, including Malawi and Zimbabwe, have sought refuge in community centres. Many left their homes with little more than a few bags when the violence began.
One is Mozambican Oscar Setuve, who registered for a temporary travel document to return home. He has lived in South Africa for 30 years, but lost everything in the riots.
"What made me run is that I saw how they were attacking people, attacking them like dogs. And some of the people who were attacking us were people that have known us for a long time. That's what hurts me the most," Setuve said.
Mozambique and Zimbabwe were also considering some sort of repatriation of their nationals.
Al Jazeera's Fahmida Miller, reporting from the airport in Johannesburg, said a small group was turned back because of "incorrect documentation".
Ofoegbu said they will have to go to the Nigerian consulate to get the right papers before travelling.
Police on high alert
It was not the first time that foreigners were attacked in South Africa.
"I am so worried about the safety of my family, because these [xenophobic] attacks keep happening, so if I don't save my family now, I don't know when [this will] start again," Ofoegbu said.
"It happened in 2008 and then in 2015, now it is repeating."
The root cause of the latest violence is still unclear, but high unemployment, poverty and criminality may have played a role.
South African officials were hesitant to describe the violence as xenophobic attacks, and instead said it was an issue of criminality that the government was trying to deal with.
"While there has been a significant decline in the number of incidents, police forces remain on high alert and are closely monitoring hotspots to ensure further violence does not erupt," Minister of Defence Nosiviwe Mapisa-Nqakula said.
Police have arrested at least 653 people, mostly South Africans but some foreigners as well, in connection to the attacks, Minister of Police Bheki Cele said.
Nigeria's President Muhammadu Buhari is expected to visit South Africa next month to discuss the violence and seek a solution.