Amid anger over an Islamic insurgency that has claimed thousands of lives, Nigerians threw out the incumbent and elected a 72-year-old former military dictator in a historic transfer of power officially announced early Wednesday following the nation's most hotly contested election ever.
President Goodluck Jonathan conceded defeat to former Gen Muhammadu Buhari, paving the way for an unprecedented peaceful transfer of power in Africa's most populous nation.
"Nobody's ambition is worth the blood of any Nigerian," Jonathan said in a televised address to the nation. "I promised the country free and fair elections. I have kept my word."
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 - considered 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 throughout 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.
Buhari was to address a news conference later Wednesday.
Jonathan's concession came before the final announcement from the Independent National Electoral Commission that Buhari had been elected. Commission chairman Attahiru Jega said Buhari received 15,424,921 votes to Jonathan's 12,853,162. He said among 12 trailing candidates the only woman, Remy Sonaiya, received 13,076 votes.
Both candidates satisfied the requirement for a victor to win at least 25 percent of votes in two-thirds of the 36 states and the Federal Capital Territory, Jega said - Buhari in 27 states and Jonathan in 26.
Buhari won 19 states to Jonathan's 17 and the small Federal Capital Territory.
Buhari, who ruled with an iron hand during a brief tenure in the 1980s, dealt a decisive 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.
Besides dominating, as expected, in his northern strongholds, 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.
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. The traditional broom is the sign of Buhari's campaign pledge to sweep out the corruption endemic in Nigeria.
"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."
Nigerians praised Jonathan for his gracious concession.
"In the history of Nigeria, I think this is the first time where a contestant has called his rival to congratulate him," retired Gen. Abdusalam Abubakar, a former head of state and head of a national peace committee, said after meeting Jonathan on Tuesday.
In the war room where Jonathan's campaign workers were crunching numbers, as it became clear their candidate might lose on Monday night, according to a person who was there and asked for anonymity because the meeting was private. She said glum campaign workers explained the situation to Finance Minister Ngozi Okonjo-Iweala, who responded: "Democracy in Nigeria is strong. There's no loss, only gain."
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.