Muhammadu Buhari
Muhammadu Buhari's has been declared the winner of the Nigerian election, beating Goodluck Jonathan Getty

Nigerian president-elect Muhammadu Buhari is nothing if not persistent – the military ruler-turned-democrat had run for the country's top job three times before his shock election last night, when he unseated President Goodluck Jonathan by more than two million votes.

In the weeks leading up to the poll it increasingly seemed that Jonathan was losing the election rather than Buhari winning it. The southern Christian incumbent lost high-profile supporters and first failed to appreciate and then to act on the growing militancy of Boko Haram, while his favouring of a small group of oil tycoons had alienated many important power brokers.

"Jonathan upset a lot of people who held a lot of power," said Andrew Walker, an analyst and journalist who was based in Nigeria for four years.

The ruling People's Democratic Party (PDP) which Jonathan headed had been haemorrhaging support in Nigeria for over two years since Buhari split from the PDP and set up the All People's Congress (APC) in 2013. The PDP has dominated Nigerian politics since the end of military rule in 1999, but the APC has attracted PDP defectors and gained momentum.

'He earned himself a reputation as a hard-nosed military ruler at the head of an uncompromising crack-down on corruption, waste and indiscipline.'
- Cathy Haenlein, RUSI

Buhari's background as an authoritarian military leader during the 1980s has raised eyebrows, but the northern Muslim leader has been candid about his conversion from ruler to democrat. He would not be the first: former president Olusegun Obasanjo ruled Nigeria as a general in the 1970s, only to return as democratically-elected president from 1999 to 2007.

Speaking after his election, Buhari said: "We have proven to the world that we are people who have embraced democracy. We have put the one-party state behind us. [...] Our country has now joined the community of nations that have used the ballot box to peacefully change an incumbent president in a free and fair election."

Buhari has made some bold claims in the run up to the poll, not least that he would end the Boko Haram insurgency "within months" after the election. He himself survived an assassination attempt in July 2014, and has – like many Nigerians – been an outspoken critic of Jonathan's perceived inaction over Boko Haram.

The ongoing campaign in the north of the country against the Islamist group, which is backed by Cameron, Niger and battle-hardened Chad, will help, but analysts point out that Buhari's criticism of the military could make his leadership of it trickier. As could the fact that he has been out of the game for more than three decades.

Just because he is from a military background doesn't means he can walk straight into the military and change it. It has been a good 30 years since he has been involved in the military in any meaningful way, everybody has changed," said Walker.

"He is presumably going to have to sack all of them and put in new people. How is he going to do that? Will there be a fightback? That is going to be a big job."

His second major pledge was to rout corruption in Nigeria, which is endemic and in the past has marred almost every democratic election – not to mention the oil and gas sector. In this, his background as ruler from 1984-85 – when he seized power in a coup – could actually serve him well.

"He earned himself a reputation as a hard-nosed military ruler at the head of an uncompromising crack-down on corruption, waste and indiscipline. Given this record, many Nigerians see him as likely to be able to provide the firm leadership required to tackle what remain deep-seated problems of graft and insecurity," said Cathy Haenlein, a research analyst at the Royal United Services Institute.

'In the last couple of years he has obviously been groomed into being a better politician.'
- Andrew Walker, Nigeria analyst and journalist

As for what kind of man Buhari is, the new president has already had to defend his age, 72, and ensure voters that his advanced years do not encumber him from running the country. It had not escaped anyone that Goodluck Jonathan's predecessor, Umaru Musa Yar'Adu, died in office.

Walker, who covered Buhari election campaigns in 2007 and 2011, said that when Buhari appeared at a Chatham House event earlier this year, he was markedly different from the naïve politician that he remembers from the leader's previous campaigns. He was able to say the right things and sound like a politician, he said.

"In the last couple of years he has obviously been groomed into being a better politician," Walker recalled.

The fact that a northern Muslim leader has replaced a southern Christian has also escaped few observers, especially given the sectarian violence that other African nations have seen over the past 12 months. But the relatively peaceful transfer of power – with Jonathan conceding the election and little violence following the result – could help to calm tensions.

"While such issues around identity have played a particularly prominent role in the 2015 elections, these polls have also seen the leaders play by the electoral rules," said RUSI's Haenlein.

"Both leaders pledged in the run up to elections to respect the outcome, with Jonathan conceding to Buhari and calling to congratulate his opponent – which may serve to reduce the divisive impact of these highly polarised elections."