The leaders of Africa's two superpowers, Nigeria and South Africa, are due to meet in the wake of recent xenophobic attacks in Johannesburg in which Nigerians were targeted.

South Africa's President Cyril Ramaphosa will be welcoming his counterpart, Muhammadu Buhari, to Pretoria and the two men will hope to put the tension behind them and focus on economic cooperation.

Our correspondents in Lagos and Johannesburg look at how the two nations view each other

--

Rivals and partners

Mayeni Jones, BBC News, Lagos

It's fair to say that there's long been a rivalry between Nigeria and South Africa. Many Nigerians see South Africa as their only other competitor on the continent for sporting prowess, cultural output and economic strength.

They're Africa's two biggest economies, taking it in turns as the top economic performer. Culturally, Nigeria's popular Afrobeats music has been a global force for years now, and its artists are some of the most famous African musicians in the world.

The country has Africa's fastest growing music industry and is projected to be worth $86m (£70m) in 2020. Nevertheless South Africa's music industry is larger still, with a projected growth of $178 million by the same year.

And all you have to do is sit with fans on either side of the aisle during a football match between national teams the Super Eagles and Bafana Bafana to feel how deep the competitive spirit between these two African giants runs.

The two nations are economic, cultural and sporting rivals

Historically, Nigeria played a key part in providing diplomatic support to the anti-apartheid movement.

And since both countries' transition to democracy, they've been economic allies. Some of the biggest companies operating in Nigeria - including the mobile network MTN, the supermarket chain Shoprite and the broadcaster MultiChoice - are all South African.

South Africa v Nigeria GDP

But despite considering them worthy competitors, many Nigerians also express disdain for what they see as a sense of entitlement from South Africans.

Previous xenophobic attacks in South Africa in 2008 and 2015 that targeted poor African migrants in the country's townships had many Nigerians feeling that South Africans were directing their anger at the wrong people.

This was expressed on the streets of Lagos and online during last month's wave of attacks in Johannesburg and other cities.

Nigerians took to social media and call-in radio shows to express their anger that once more, other Africans were being targeted for trying to make a living in South Africa. TV shows on Nigeria's satellite channels had one commentator after another condemning the violence.

If South Africans worked harder, was their reasoning, then their African peers would not be making more money from them. And anyway, shouldn't they be angry at the white South Africans dominating their economy?

This anger spilled out onto the streets of Nigeria's urban centres. Young people, allegedly motivated by a need for revenge, and fuelled by fake videos and photos on social media, started looting and burning South African businesses.

Both governments were too slow in clarifying that no Nigerian lives were lost in the violence. They underestimated the anger online propaganda can whip up.

South Africa v Nigeria GDP per capita