CAPE TOWN (Reuters) - Nigeria said on Wednesday it would boycott an Africa economic summit in Cape Town, intensifying a diplomatic row after a series of deadly attacks on foreigners in South African cities.

The withdrawal of Nigerian Vice President Yemi Osinbajo from the World Economic Forum gathering has cast a cloud over initiatives to boost intra-African trade. He was scheduled to address a panel on universal energy access on Thursday.

The rioting has killed at least five people in Johannesburg and Pretoria in recent days, and on Wednesday South African companies MTN and Shoprite closed stores in Nigeria after retaliatory attacks on their premises.

South African President Cyril Ramaphosa, on a charm offensive to attract $100 billion of new investment, tried to limit fallout from the violence, which has rekindled memories of previous deadly attacks on foreigners that also led to reprisals on South African businesses abroad.

Police have made almost 300 arrests, while people across the continent have protested and voiced their anger on social media.

It is unclear what ignited the latest attacks, which mainly targeted shops owned by African migrants, but unemployment is high and many South Africans feel frustration with limited economic opportunities.

Old wounds between Africa's two biggest economies have also been reopened.

"Clearly with this climate, he (Osinbajo) and Mr. President have agreed that he should not go," Nigerian Foreign Minister Geoffrey Onyeama told a news briefing.

Onyeama had previously summoned South Africa's envoy to Nigeria and demanded an explanation for "the continued burning and looting of Nigerian shops and premises ... with ineffective police protection".

Ramaphosa said on Wednesday that South Africans should never take justice into their own hands against people from other countries.

"We need to quell those incidents of unrest," Ramaphosa said. "South Africa must be a country where everyone feels safe," Ramaphosa said, also condemning recent incidents in which women had been killed.

Hundreds of mainly female students protesting about violence against women tried to storm the conference center in Cape Town.

They were pushed back by police who later used stun grenades against demonstrators. Demonstrators held placards including "Women are not sexual objects" and chanted "We want justice" as they banged on conference doors to try to force their way in.

"Women get raped in this country every single day and nothing is happening. The president is sitting there inside having a fancy lunch with all these people trying to sell our country to the world, (while) there is no peace and no justice," said a student protester from the University of Cape Town, who declined to be identified.

REGIONAL INTEGRATION

Rwandan President Paul Kagame and Malawi's Peter Mutharika also pulled out of the conference, but their governments did not give an official reason for their no-show.

South Africa's Department of International Relations and Cooperation, commenting before Nigeria announced Osinbajo's withdrawal, said attendance was "satisfactory".

WEF spokesman Oliver Cann said Kagame and Mutharika had informed conference organizers by Saturday - before the attacks had started - that they could not attend.

Zimbabwe's Foreign Minister Sibusiso Moyo told Reuters the attacks were "unfortunate ...in an environment where we are looking forward to regional integration and co-operation."

He is part of a large Zimbabwean delegation including President Emmerson Mnangagwa.

There are a significant number of Zimbabweans living in South Africa and they, along with Somalians and Nigerians, have formerly borne the brunt of attacks on foreigners.

Immigration to South Africa from Africa and parts of southeast Asia picked up in the early 1990s, spurred by the end of apartheid and the economic boom that followed.

But in recent years, attacks against foreign-owned businesses have become a regular occurrence as frustration has increased over mounting unemployment, currently at a decade high around 29%.

Some 60 people were killed in attacks directed at foreigners in 2008 and at least seven more in 2015.

Hundreds of University of Zambia students dressed mostly in black and chanting "No Violence" protested outside the South African High Commission on Wednesday. Zambia criticized them for burning a billboard.

On Tuesday, the Football Association of Zambia (FAZ) called off the country's friendly soccer international against South Africa in Lusaka on Saturday, citing "prevailing security concerns in South Africa".

(Reporting by Alexander Winning and Wendell Roelf in Cape Town and Felix Onuah in Abuja; Additional reporting by Nqobile Dludla and Onke Ngcuka in Johannesburg and other Reuters reporters in Africa; Editing by Alison Williams and John Stonestreet)