JOHANNESBURG, South Africa — Those who attack and kill foreigners in South Africa have little to fear: such crimes are rarely punished.

As the South African government scrambles to contain a spate of xenophobic violence, mostly aimed at poor migrants from other African countries, researchers are pointing to a culture of impunity as a worrying factor in the unrest.

Take, for example, the case of Ernesto Nhamuave, a Mozambican man beaten, stabbed and burned alive by a mob in a squatter camp near Johannesburg during a wave of anti-foreigner attacks in 2008.

Photographs of Nhamuave's horrific death made headlines around the world, and became a dominant image of the violence that displaced 100,000 and left 62 dead.

But no one was ever arrested for Nhamuave's murder, with the official reason being that there were no suspects and no witnesses. Yet when a South African journalist visited the site of the murder earlier this year, he found an eyewitness who quickly pointed out the main suspects.

Jean-Pierre Misago, a researcher at the African Center for Migration and Society in Johannesburg, estimates that at least 350 foreigners have been killed in xenophobic violence since 2008. But Misago, who has been tracking these attacks, said he has only heard of one murder conviction, with very few cases making it to court.

''This leads to a culture of impunity and it's dangerous because [killers] are getting away with it," Misago told South Africa's Sunday Times.

"The South African government has lost its power to enforce law and order in the country. They have lost control and people are taking advantage," he said.

In the latest attacks, which began in the coastal Durban area earlier this month, thousands of foreigners have been displaced and at least seven killed.

The violence began following comments by King Goodwill Zwelithini, traditional leader of the Zulus — the ethnic majority in KwaZulu-Natal, the province that includes Durban — telling foreigners to return home. Zwelithini claims his remarks were misinterpreted.

Some South Africans accuse foreign migrants of taking their jobs, in a country where the official unemployment rate is 25 percent.

In Alexandra, a township in Johannesburg, four men stabbed and killed a Mozambican man named Emmanuel Sithole this month, with the incident captured by a news photographer. Like the 2008 murder of Ernesto Nhamuave, the images shocked South Africa.

But this time, the police have made arrests, with four men appearing in court Tuesday in connection with Sithole's death.

Following attacks on foreign-run small shops in Soweto earlier this year, Marc Gbaffou, chairman of the African Diaspora Forum, told GlobalPost that there is a "culture" in South Africa of communities taking anger and frustration out on migrants.

“We think it is very important that government comes with a strong message that the perpetrators should be held accountable,” he said.