IT’S impossible not to like Nigerians. A combination of resilience and optimism has seen Africa’s most populous nation survive alacrity of profiling insults like no other on the continent: according to local legend, Nigerians are all dishonest cocaine merchants and 419 fraudsters who descend from a legacy of systematic oil corruption and make crap movies.

Lagos is riding a wave of optimism, with good reason — if popular Finance Minister Ngozi Okonjo-Iweala is to be believed, the Nigerian economy is on a growth path that will see it overtake South Africa as Africa’s biggest by the mid-2020s. The retail and wholesale sectors now account for 20% of gross domestic product. The share of oil in export earnings is down to 70% from 98%. A vicious debt hangover is being confronted and the energy, aviation and agricultural industries will soon be able to import equipment at a zero-duty rate.

Competition between South Africa and Nigeria is not limited to economics, either — "in Nigeria, we have Goodluck Jonathan, in South Africa you have Badluck Jacob" is the word on the streets of Lagos.

But the influx of good fortune betrays a history that is anything but. Even a brief glance over the world’s history of oil will tell you that whoever coined the phrase "resources curse" was probably staring at Nigeria. Its reserves — more than 30-billion barrels — make it the 10th most petroleum-rich nation on the planet, by far Africa’s most affluent. The oil, known as sweet, largely lacks the sulphur of the Middle East’s reserves. But what started as a welcome discovery in the Niger Delta in the 1950s by the Dutch-British joint venture Shell-BP ultimately plunged the country into chaos.

Five years after the discovery of oil, Nigeria achieved independence from Britain. The federal government’s role in the oil industry was initially limited to taxes and royalties but, following the civil war primarily engineered by Igbo secessionists, the country became trapped in an era of army generals and patronage.

Prompted by a desire to join the Organisation of the Petroleum Exporting Countries, where member states are required to own a 51% stake, Nigeria nationalised its oil industry and created the shadowy Nigerian National Petroleum Corporation. Democracy beckoned in 1979 and then military head of state Olusegun Obasanjo handed over power to the National Party of Nigeria, though repeated miscarriages of justice and transparency ensured that the 1983 elections were simply another spring for another coup. At this point it emerged that the $101bn Nigeria had received in oil and tax royalties since 1956 had disappeared into Swiss and Cayman Islands bank accounts.

In 1993, Gen Ibrahim Babangida, who himself had overthrown his predecessor, started making similar overtures toward democracy — primarily due to the rotten state of the economy and the fact the federal government had squandered or stolen the Gulf War oil windfall of $12bn earned between 1988 and 1993. But this was only an illusion. Enter one of history’s nastiest men: Gen Sani Abacha, who ferociously accelerated graft in Nigeria and declared himself above the courts.

There is a peculiar thread that villains share: from the Saudi royal family to Slobodan Milosevic, all have looted with the complicity of their sons. Mohammed Abacha’s involvement in the siphoning of $5bn during his father’s reign shows an unprecedented degree of impunity: ordinary Nigerians regard it as a mystery not because Abacha Jnr is remotely innocent, but because he is, apparently, "very thick". One imagines a young man wearing pyjamas presenting Swiss bankers with a book of numbers and colours.

Simple offspring aside, it was an incident in 1995 that captured the world’s horror and perhaps came to define Nigeria’s tragic relationship with oil. In the heart of the Niger Delta, an activist poet named Ken Saro-Wiwa became a founding member of the Movement for the Survival of the Ogoni People (Mosop), which advocated rights for the disenfranchised Ogoni people, demanding a greater share of oil revenues and reparation to an environment damaged by Shell’s operations.

But Sani Abacha took exception. On November 10 1995, Saro-Wiwa and eight of his colleagues were hanged by a military tribunal. Saro-Wiwa was intentionally hanged last, after being forced to watch his colleagues perish. Nigeria was swiftly suspended from the Commonwealth.

Mercifully, in 1998, while in the company of two Indian prostitutes imported from Dubai, Abacha suffered a massive coronary. Shell’s reputation, however, was harmed forever; in 2009, despite denying liability, it settled with the Saro-Wiwa family for $15m.

In pre-1994 election canvassing, former South African president Nelson Mandela cast the African National Congress as a party standing in solidarity with the continent’s oppressed. Nigerians were listening and soon started arriving in Johannesburg. Today they constitute the largest group of immigrants in South Africa behind Zimbabweans, and they prosper and thrive given the opportunities that economic freedom brings.

Among the first arrivals was a young man named Henry Okah, who would become the leader of an organisation styling itself as a successor to Mosop. But where Saro-Wiwa promoted non-violence, the Movement for the Emancipation of the Niger Delta (MEND) is viciously militant.

In 2007, war correspondent Sebastian Junger traced MEND to a high-rise in Hillbrow, Johannesburg, from where instructions emanated via SMS. It has become increasingly sophisticated and its transcontinental presence has made it virtually impossible to dismantle. Okah’s conviction and incarceration in South Africa this year for a 2010 attack on Abuja in which 12 people died has only angered the movement: this year alone has brought 35 attacks, many featuring casualties.

The combination of oil and frustrated activism has a habit of inspiring opportunistic, if irreverent, religious extremism. This is the case of Boko Haram, a violent Islamist sect based in northeast Nigeria, Niger and Cameroon whose name roughly translates as "Western education is sinful". Its founder, the late Mohammed Yusuf, initially attracted followers — mostly disaffected youths — by claiming to speak out against oil-related corruption before reverting to the more conventional recesses of jihadi practice.

Many Nigerians are deeply resentful of Boko Haram and blame former dictator Babangida for the country’s membership of the Organisation of Islamic Co-operation, despite less than 50% of the population being Muslim.

How the country will overcome its oil curse remains to be seen, of course, but downplaying the prominence of oil in the economy by advancing other sectors is, like most Nigerians, enterprising to say the least.

• Reader is the co-founder and chief investment officer of RE:RE Capital.