Africa was one of only two regions in the world to experience an increase in foreign direct investment in 2012 but inflows to regional giants Nigeria and South Africa declined, a United Nations report said on Wednesday.

While global FDI fell by 18 percent last year, Africa bucked the trend with inflows increasing 5 percent to $50 billion, as countries like Mozambique, Tanzania and Uganda reaped the benefits of new discoveries of oil and gas, according to the 2013 World Investment Report published by the United Nations Conference on Trade and Development.

South America was the only other region to see a year-on-year rise in FDI inflows, which grew 12 percent, though flows to the Latin America and Caribbean region as a whole declined.

Although West Africa had the biggest share of investment, flows to the region declined by 5 percent to $16.8 billion largely due to decreased investment in the continent’s top oil producer Nigeria. Its FDI inflows fell from $8.9 billion in 2011 to $7 billion last year due to political insecurity and a weak global economy, UNCTAD said.

Nigeria is fighting an insurgency in the north against Islamist sect Boko Haram which has killed thousands of people in the past three years.

FDI flows to South Africa slumped 24 percent to $4.6 billion in 2012, largely due to a foreign mining company offloading its stake in a South African subsidiary, the report said.

However, inflows to its neighbour Mozambique, where companies like Brazil’s Vale and London-listed Rio Tinto are developing huge offshore gas and coal deposits, doubled to $5.2 billion.

FDI to central Africa surged 23 percent to a record $10 billion, while in east Africa recently discovered gas reserves in Tanzania and oil fields in Uganda resulted in a 40 percent jump to $6.3 billion.

The report also found that African countries, led by South Africa and Angola are stepping up their investment overseas, with FDI outflows from the continent nearly tripling from $5 billion in 2011 to $14 billion last year.