ABUJA, Nigeria -- Amid anger over an Islamist insurgency that has claimed thousands of lives, Nigerians returned a 72-year-old former military dictator to power Tuesday in the most hotly contested election in the country's history.
Incumbent Goodluck Jonathan conceded defeat to Muhammadu Buhari, a Cabinet minister close to the outgoing president told The Associated Press, paving the way for an unprecedented peaceful transfer of power in Africa's most populous nation.
It will be the first time in Nigeria's history that an opposition party has democratically taken control of the country from the ruling party -- a sign of the West African nation's maturing young democracy. Jonathan's party has governed since decades of military dictatorship ended in 1999.
Celebrations erupted all over Buhari's strongholds in northern Nigeria and around his campaign headquarters in Abuja. Cars honked and people waved brooms in the air -- a symbol of Buhari's campaign promise to sweep out Nigeria's endemic corruption.
Jonathan called Buhari to congratulate him Tuesday evening, thus conceding defeat, Aviation Minister Osita Chidoka said.
Jonathan's concession came before the final announcement of election results by the Independent National Electoral Commission and as both he and Buhari prepared to address the nation.
Results of all 36 states and the Federal Capital Territory showed Buhari, a former general who ruled with an iron hand during a brief tenure in the 1980s, dealing a crushing defeat to Jonathan.
He won overwhelmingly in the final state to report results, northeastern Borno, the birthplace of the brutal Islamic insurgent group, Boko Haram, and the one that has endured the worst suffering from the Islamic uprising that has swept through villages and towns in the north, killing thousands of civilians and kidnapping many more, including hundreds of schoolgirls.
An Associated Press count of the final results showed Buhari winning more than 15.3 million votes to Jonathan's 12.9 million. Buhari won 19 states to Jonathan's 17 states and the small Federal Capital Territory. Final official results were expected to be announced late Tuesday.
Besides dominating, as expected, in his northern strongholods, Buhari crucially carried Lagos state, Nigeria's commercial hub with the largest number of voters, though fewer than one-third of eligible voters participated. He also took other critical competitive states in the country's southwest.
The victorious candidate must take more than half of all votes and at least 25 percent of votes in two-thirds of the 36 states and the Federal Capital Territory at Abuja.
Spontaneous celebrations sprang up across cities in northern Nigeria, where Buhari is almost revered. Young men on motor scooters performed wheelies as hundreds of youths chanted, "Change! Change! Change!" and cars honked their horns in support. In Kano state, Buhari delivered a crushing defeat to Jonathan, winning 1.9 million votes to Jonathan's 215,800.
Outside Buhari's party headquarters in Abuja, women chanted songs and used grass brooms to elaborately sweep the way ahead of arriving dignitaries in flamboyant robes.
"This election is not about Buhari or Jonathan, it's about Nigeria, it's about freedom, it's about change, it's about unity," Aisha Birma said.
She said Jonathan lost because he failed to provide security for Nigerians.
"What we have gone through, the Boko Haram insurgency for the past six years in Borno. ... You, Jonathan, were responsible for our lives and property. When you don't protect our lives and property, you can't talk about infrastructure, education ... Security is paramount," she said.
The austere and strict Buhari has described himself as a belated convert to democracy, promising that if elected, he would stamp out the insurgency in the north waged by Boko Haram, the homegrown Islamic extremist group that has pledged fealty to the Islamic State group.
Critics and supporters alike agree that Buhari is the one leader who did not treat the country's treasury as a personal piggy bank. During his brief 1983-1985 dictatorship he ruled with an iron fist, jailing people even for littering, and ordering civil servants who arrived late to work to do squats. He gagged the press and jailed journalists to cover up a deepening economic crisis as prices tumbled for the oil on which Nigeria's economy depends. He eventually was overthrown by his own soldiers.
Nigeria's 170 million people are divided almost equally between Christians mainly in the south and Muslims, like Buhari, who dominate the north. In this election Buhari for the first time won states in the southwest and even took one-third of votes in a southeastern state -- an unprecedented development that many say was more a reflection of voter antipathy toward Jonathan than pro-Buhari sentiment.
Buhari's showing in his fourth bid to become president was boosted by the formation of a coalition of major opposition parties two years ago. Its choice of Buhari as a single candidate presented the first real opportunity in the history of Nigeria to oust a sitting president.
Buhari also was able to count on considerable voter dissatisfaction with the performance of Jonathan, who has been president since 2010.
"If indeed Buhari becomes president, it sends a clear message to the people in government that you cannot take the people of Nigeria for granted and that Nigerian democracy is maturing," said journalist and political analyst Kadaria Ahmed.
She cited Jonathan's perceived insensitivity to the suffering of citizens caught up in the mayhem of Boko Haram's uprising, in which some 10,000 people were killed last year and more than 1.5 million people have been driven from their homes, as stoking opposition to his re-election.
"Boko Haram was a factor both as a security threat to Nigeria, but also because it became emblematic of a broader failure of the incumbent administration. It became the icon of its shortcomings," said J. Peter Pham, director of the Atlantic Council's Africa Center.
The Nigerian military, with help from regional troops, forced Boko Haram out of areas the insurgents had taken in recent months as they formed their self-styled "caliphate."
There were vote-counting delays in about a dozen states because of logistical challenges that had election material being delivered by air, road, speedboat, mules and camels, spokesman Kayode Idowu of the Independent National Electoral Commission said.
Earlier Tuesday, Buhari's spokesman, Garba Shehu, told the AP that Buhari feared his victory could be stolen by "tricks" from the government. Jonathan's campaign has denied warnings from Britain and the United States of possible political meddling in the final tally of votes from Saturday's election.
In Abuja, the count was disrupted Tuesday by a representative of Jonathan's party who protested that the proceedings were partial to Buhari. "We have lost confidence in you. You are tribalistic! You are partial!" shouted former Cabinet minister Peter Godsday Orubebe to the chairman of the electoral commission counting the vote.
The opposition also complained that electoral officials were partisan. The count was being carried out in the presence of party representatives, national and international observers and media.
Because of decades of military dictatorship, Saturday's vote was only the eighth election since the country won independence from Britain in 1960, and the fifth since democracy was restored in 1999.