Prior to 1994, Economic migrants from Africa faced resistance and even occasional violence in South Africa due to competition for scarce economic opportunities. After majority rule in 1994, contrary to expectations, the incidence of xenophobia increased. In 2008, at least 62 people were killed in the xenophobic uprising and attacks. In 2015, another nationwide spike in xenophobic attacks against immigrants in general prompted a number of foreign governments to begin repatriating their citizens. A Pew Research poll conducted in 2018 showed that 62% of South Africans expressed negative sentiment about foreign nationals living and working in South Africa, believing that immigrants are a burden on society by taking jobs and social benefits and that 61% of South Africans thought that immigrants were more responsible for crime than other groups. There is no factual evidence to substantiate the notion that immigrants are the main culprits of criminal activity in South Africa, even though the claim is incorrectly made sometimes by politicians and public figures. Between 2010 and 2017 the number of foreigners living in South Africa increased from 2 million people to 4 million people. The proportion of South Africa's total population that is foreign born increased from 2.8% in 2005 to 7% in 2019, according to the United Nations International Organization for Migration, South Africa is the largest recipient of immigrants on the African continent.

Xenophobia in South Africa before 1994 Local people and immigrants have faced discrimination and even violence in South Africa due to competition for scarce economic opportunities. Xenophobia has a long and complex history and many instances of state sanctioned Xenophobia can be found in South Africa's history. For example, in 1820, poor English migrants or settlers sought a better life Tosh, J. (2017). From the ‘cape of despair’ to the Cape of Good Hope: letters of the emigrant poor in early nineteenth-century England. Social History, 42(4), 480–500. https://doi.org/10.1080/03071022.2017.1368233 in the Zuurveld region (now Albany) and emigrated to this area under a government scheme. A series of Xhosa Wars had dispossessed Xhosa tribes of their land and had made this migration possible. This Xhosa dispossession / English expansion continued. In 1835, land west of the Kei River was annexed by Benjamin D'urban (this was reversed) and then again in 1847, when the British Empire extended its influence beyond the Cape of Good hope into an undefined area and appointed Sir Harry Smith as Governor and High Commissioner of the Cape Colony. Who conquered the Ngqika and the Ndlambe, and re-annexed Kaffraria. Smith was also known for his pantomimes of power, including blowing up wagons when negotiating with local chiefs. Attacks against Mozambican and Congolese immigrants Between 1984 and the end of hostilities in that country, an estimated 50,000 to 350,000 Mozambicans fled to South Africa. While never granted refugee status they were technically allowed to settle in the bantustans or black homelands created during the apartheid system. The reality was more varied, with the homeland of Lebowa banning Mozambican settlers outright while Gazankulu welcomed the refugees with support in the form of land and equipment. Those in Gazankulu, however, found themselves confined to the homeland and liable for deportation should they officially enter South Africa, and evidence exists that their hosts denied them access to economic resources.

Unrest and civil war likewise saw large numbers of Congolese people emigrate to South Africa, many illegally, in 1993 and 1997. Subsequent studies found indications of xenophobic attitudes towards these refugees, typified by them being denied access to the primary healthcare to which they were technically entitled.

Xenophobia in South Africa after 1994 Despite a lack of directly comparable data, xenophobia in South Africa is perceived to have significantly increased after the election of a Black majority government in 1994.From 'Foreign Natives' to 'Native Foreigners': Explaining Xenophobia in Post-Apartheid South Africa, Michael Neocosmos, CODESRIA, Dakar, 2010 Academic Audie Klotz states that following South Africa's transition to democracy in 1994 a new "non-racial xenophobia" has emerged in the country that has specifically targeted refugees. According to a 2004 study published by the Southern African Migration Project (SAMP):

"The ANC government – in its attempts to overcome the divides of the past and build new forms of social cohesion ... embarked on an aggressive and inclusive nation-building project. One unanticipated by-product of this project has been a growth in intolerance towards outsiders ... Violence against foreign citizens and African refugees has become increasingly common and communities are divided by hostility and suspicion."

The study was based on a citizen survey across member states of the Southern African Development Community (SADC) and found South Africans expressing the harshest anti-immigrant sentiment, with 21% of South Africans in favour of a complete ban on foreign entry and 64% in favour of strict limitations on the numbers permitted. By contrast, the next-highest proportion of respondents in favour of a complete ban on immigration were in neighbouring Namibia, and Botswana, at 10%.

Foreigners and the South African Police Service

A 2004 study by the Centre for the Study of Violence and Reconciliation (CSVR) of attitudes amongst police officers in the Johannesburg area found that 87% of respondents believed that most undocumented immigrants in Johannesburg are involved in crime, despite there being no statistical evidence to substantiate the perception. Such views combined with the vulnerability of illegal aliens led to abuse, including violence and extortion, some analysts argued.

In a March 2007 meeting with Home Affairs Minister Nosiviwe Mapisa-Nqakula, a representative of Burundian refugees in Durban claimed that immigrants could not rely on police for protection, but instead found police mistreating them, stealing from them and making unconfirmed allegations that they sell drugs. Two years earlier, at a similar meeting in Johannesburg, Mapisa-Nqakula had admitted that refugees and asylum seekers were mistreated by police with xenophobic attitudes.

Violence before May 2008 According to a 1998 Human Rights Watch report, immigrants from Malawi, Zimbabwe and Mozambique living in the Alexandra township were "physically assaulted over a period of several weeks in January 1995, as armed gangs identified suspected undocumented migrants and marched them to the police station in an attempt to 'clean' the township of foreigners." The campaign, known as "Buyelekhaya" (go back home), blamed foreigners for crime, unemployment and sexual attacks.

In September 1998, a Mozambican national and two Senegalese citizens were thrown out of a train. The assault was carried out by a group returning from a rally that blamed foreigners for unemployment, crime and the spread of AIDS.

In 2000, seven foreigners were killed on the Cape Flats over a five-week period in what police described as xenophobic murders possibly motivated by the fear that outsiders would claim property belonging to locals.

In October 2001, residents of the Zandspruit informal settlement gave Zimbabwean citizens ten days to leave the area. When the foreigners failed to leave voluntarily, they were forcefully evicted and their shacks were burned down and looted. Community members said they were angry that Zimbabweans were employed whilst locals remained jobless and blamed the foreigners for a number of crimes. No injuries were reported amongst the affected Zimbabweans.

In the last week of 2005 and first week of 2006, at least four people, including two Zimbabweans, died in the Olievenhoutbosch settlement after foreigners were blamed for the death of a local man. Shacks belonging to foreigners were set alight and locals demanded that police remove all immigrants from the area.

In August 2006, Somali refugees appealed for protection after 21 Somali traders were killed in July of that year and 26 more in August. The immigrants believed the murders to be motivated by xenophobia, although police rejected the assertion of a concerted campaign to drive Somali traders out of townships in the Western Cape.

Attacks on foreign nationals increased markedly in late-2007 and it is believed that there were at least a dozen attacks between January and May 2008. The most severe incidents occurred on 8 January 2008 when two Somali shop owners were murdered in the Eastern Cape towns of Jeffreys Bay and East London, then in March 2008 when seven people were killed including Zimbabweans, Pakistanis and a Somali national after their shops and shacks were set alight in Atteridgeville near Pretoria.

May 2008 riots

On 12 May 2008 a series of riots started in the township of Alexandra (in the north-eastern part of Johannesburg) when locals attacked migrants from Mozambique, Malawi and Zimbabwe, killing two people and injuring 40 others. Some attackers were reported to have been singing Jacob Zuma's campaign song Umshini Wami (). In the following weeks the violence spread, first to other settlements in the Gauteng Province, then to the coastal cities of Durban and Cape Town. Attacks were also reported in parts of the Southern Cape, Mpumalanga, the North West and Free State.

By the end of the riots 62 people were reported dead. 1400 suspects were arrested in connection with the violence. Nine months after the attacks 128 individuals had been convicted and 30 found not guilty in 105 concluded court cases. 208 cases had been withdrawn and 156 were still being heard. One year after the attacks prosecutors said that 137 people had been convicted, 182 cases had been withdrawn because witnesses or complainants had left the country, 51 cases were underway or ready for trial and 82 had been referred for further investigation. The Central Methodist Mission, Johannesburg became a sanctuary for many during the unrest.

In May 2009, one year after the attacks the Consortium for Refugees and Migrants in South Africa (Cormsa) said that foreigners remained under threat of violence and that little had been done to address the causes of the attacks. The organisation complained of a lack of accountability for those responsible for public violence, insufficient investigations into the instigators and the lack of a public government inquiry.

2009–12

In late May 2009, reports emerged regarding a possible resurgence of xenophobic related activity and the organising of attacks in the Western Cape. Reports of threats and secret meetings by local businessmen surfaced in Gugulethu, Khayelitsha and Philippi, Cape Town. Samora Machel in Philippi once again emerging as a flash-point. In Gugulethu, reports emerged of secret meetings by local businessmen discussing 'what to do about Somali shopkeepers'. The Anti-Eviction Campaign brought these issues to the open by organising a series of anti-xenophobia meetings attempting to find the root cause of the crisis.