DAKAR, Senegal — Pop stars have announced a boycott. Air Tanzania has suspended flights to Johannesburg. Madagascar and Zambia are refusing to send their soccer teams. Nigeria has recalled its ambassador and pulled out of a major economic forum.

South Africa is facing a backlash after rioters in and around Johannesburg targeted immigrants from other African countries this week, torching their shops and leading to at least 10 deaths. Now, angry citizens and governments across the continent are lashing out at South Africa and its businesses, denouncing what they call “xenophobia.”

Africans across the continent once rallied behind South Africans in their struggle to defeat the apartheid government, which was finally replaced in elections held 25 years ago. Now, some Africans find themselves in the unfamiliar position of protesting the actions of the same communities in South Africa that they once stood with in solidarity.

“The only time we’ve seen this type of cooperation of African countries in terms of backlash,” said Tunde Leye, a partner at the Nigerian political research firm SBM Intelligence, “was in terms of support of the anti-apartheid movement.”