PRETORIA, South Africa — The president of South Africa vowed on Thursday that “early warning mechanisms” would be put in place to try to avoid further violence against immigrants in his country, after a series of deadly attacks prompted anger from other African leaders and an extraordinary airlift of Nigerians.

The South African leader, Cyril Ramaphosa, made the comments during a summit with his Nigerian counterpart, Muhammadu Buhari, who called the attacks “unacceptable.”

At least 12 people were killed and more than 700 arrested after gangs in Johannesburg and Pretoria attacked foreign-owned stores and stalls, looting and burning the small businesses and attacking some shopkeepers.

Outbreaks of violence against Nigerians and citizens of other African nations have regularly erupted in South Africa in recent years, with some in the country accusing foreigners of taking their jobs or of committing crimes like peddling illegal drugs.