A South African envoy to President Cyril Ramaphosa apologised "profusely" to the Nigerian government after a spate of deadly xenophobic attacks that rocked Johannesburg and Pretoria.
Jeff Radebe was in Nigeria's capital, Abuja, to attend a meeting on Monday to convey "sincerest apologies about the incident that has recently transpired in South Africa".
"The incident does not represent what we stand for," Radebe said, adding South African police would "leave no stone unturned, that those involved must be brought to book".
The Nigerian government said in a statement following the meeting: "President [Muhammadu] Buhari responded to profuse apologies from the South African president, pledging that relationship between the two countries will be solidified."
Foreign workers in South Africa - the continent's second-largest economy after Nigeria - are often victims of anti-immigrant sentiment in a nation where almost one-third of people are unemployed.
At least 12 people were killed in recent weeks after 1,000 foreign-owned business were targeted.
The violence prompted reprisal attacks against South African firms in Nigeria and the temporary closure of South Africa's diplomatic missions in Lagos and Abuja.
The violence sparked an international outcry and calls for a boycott of South Africa.
Following the violence, Nigeria announced it would repatriate more than 600 nationals to protect them from future violence.
Besides the hundreds of Nigerians returning to their home country, more than 700 people from other countries, including Malawi and Zimbabwe, sought refuge in South African community centres.
Many left their homes with little more than a few bags when the attacks began.
In 2008, at least 62 people, including South Africans, were killed in violence and looting targeting foreign-owned stores.