Nigerians are so used to the idea that an incumbent should win presidential elections that President Goodluck Jonathan's failure to beat Gen Muhammadu Buhari needs some explaining.
Here are five reasons why the opposition won:
1: Harder to rig
Past elections have been marred by serious irregularities and suspicions of rigging. In 2007 observers said the presidential poll was not "credible". In 2011 the vote was considered to be better run but observers said that rigging and fraud still took place.
This time the electoral commission took more steps to prevent rigging, including new biometric voters cards.
Also President Jonathan's party, the People's Democratic Party (PDP), had lost control of some key states which meant it could not control the electoral process there.
2: Boko Haram and security
The election took place against the background of an Islamist insurgency in the north-east of the country. The Boko Haram militant group has killed 20,000 people and forced some three million others from their homes and President Jonathan was criticized for not getting to grips with this.
The poll was delayed for six weeks to give time for the security situation to improve, but even though most areas controlled by Boko Haram were recaptured, it seems to have come too late for many people.
3: United opposition, crumbling PDP
The PDP has been described as an election-winning machine. When it was created it united a northern elite with leading politicians from the south, but that alliance has broken up and the party lost some key figures. Even former President Olusegun Obasanjo came out against Mr Jonathan.
At the same time, the opposition managed to unite under the All Progressives Congress (APC) banner. The last six weeks of desperate and dirty campaigning, in which the APC responded in kind, was not enough to turn the tide.
Nigeria is Africa's biggest oil producer and its largest economy, but many fail to feel the benefits with nearly half the population living below the poverty line. Continued corruption is seen as partly being to blame.
National income is due to grow by more than 5% this year and next year, but people did not seem in the mood to thank Mr Jonathan for this.
5: Time for a change
APC supporters chanted "change" wherever they went and it seems to have caught the mood. The PDP has been in power since the end of military rule in 1999, and 2015 is the year that Nigerians decided that someone else should have a go at sorting things out.
President-elect Buhari now has to prove he really can change things.
Source: BBC UK