By Tim Cocks and Alexis Akwagyiram
ABUJA (Reuters) - Three decades after seizing power in a military coup, Muhammadu Buhari became the first Nigerian to oust a president through the ballot box, putting him in charge of Africa's biggest economy and one of its most turbulent democracies.
As the scale of this weekend's electoral landslide became clear, President Goodluck Jonathan called Buhari on Tuesday to concede defeat to the opposition leader, Buhari's camp said, an unprecedented step that should help to defuse anger among Jonathan's supporters.
In the religiously mixed northern city of Kaduna, where 800 people were killed in violence after the last elections in 2011, Buhari supporters streamed onto the streets, waving flags, dancing and singing in celebration.
There was no word from Jonathan himself. But supporters in the Niger Delta, the defeated president's home area and the heart of Africa's biggest oil and gas industry, were despondent.
"Goodluck is a stupid man for conceding, a disappointment for Nigeria," one waitress in the oil city of Port Harcourt said, throwing a beer bottle top at a fridge.
Jonathan's People's Democratic Party (PDP) has been in charge since the end of army rule in 1999 but had been losing popularity due to a string of corruption scandals and the rise of Boko Haram's Islamist insurgency in the northeast.
"At about 5 minutes to 5, President Jonathan called General Muhammadu Buhari, the winner of the elections, to congratulate him," Lai Mohammed, a spokesman for Buhari's All Progressives Congress (APC), told reporters at the party's headquarters in the capital, Abuja.
"There had always been this fear that he might not want to concede but he will remain a hero for this move," he added. "The tension will go down dramatically."
Around him, women in brightly colored dresses danced and sang, ululating in celebration.
A final tally of the results compiled by Reuters gave the sandal-wearing and ascetic Buhari 15.4 million votes against 13.3 million for Jonathan, a margin of victory that is likely to render any legal challenges irrelevant.
Despite some technical glitches and the killing of more than a dozen voters by Boko Haram gunmen, the election has been the smoothest and most orderly in Nigeria's history.
"There are probably lots of reasons why the PDP might have lost but I think the key one is that the elections just haven't been rigged," said Antony Goldman, a business consultant with high-level contacts in Nigeria.
As the results trickled in, Buhari, dressed in a white khaftan and prayer cap, sat calmly in a front a television at a house in the capital.
Buhari seized power in a 1983 coup only to be ousted 18 months later by another general. Since then Buhari has declared himself a convert to democracy, running and losing several elections but always coming back for more on a ticket of cleaning up Nigeria's dirty politics.
Before Jonathan conceded defeat, Buhari received a tacit endorsement from Washington, with a U.S. official acknowledging his role in building a "new" Nigeria, a pillar of a rapidly modernizing and growing continent.
"His leadership of the opposition over these years has demonstrated a commitment to democracy that would seem to suggest he is participating in Nigeria's new era that began in 1999," the U.S. official said.
Buhari's inner circle acknowledged the hard work ahead in building bridges in a country of 170 million people split along ethnic, religious and regional lines.
He must also deal with the fallout from a dive in global oil prices in the last eight months which has hammered the economy, squeezed state revenues and forced two de facto devaluations of the currency, the naira.
"We should all work together to redirect the country. A lot of sacrifices will have to be made," Kwara state senator and senior APC official Bukola Saraki said.
In a sign of the simmering PDP passions, Godsday Orubebe, a former Niger Delta minister, grabbed a microphone at the headquarters of the election commission to lambaste its chief.
"Mr. Chairman, we have lost confidence in what you are doing," he shouted, as nervous security guards stood around, wondering what to do. "You are being very, very selective. You are partial."
At least 15 people were shot dead during polling, most of them in the northeast where Boko Haram has declared war on democracy in its fight to revive a mediaeval caliphate in the southern Sahara.
However, the chaos was significantly less than in previous elections, a reality that pushed the stock market up more than 2 percent toward a three-month high. The naira also held steady at 218 against the dollar on the black market.
Although the economy has been growing at 7 percent or more, scandals over billions of dollars in missing oil funds and the rise of Boko Haram hit Jonathan hard in the polls.
His perceived slow reaction to the kidnapping of more than 200 schoolgirls last April caused widespread anger, and fueled a public appetite for decisive military action against Boko Haram from a strongman such as Buhari.
The war has turned in Jonathan's favor in the past six weeks with external intervention by troops from neighboring Chad, Cameroon and Niger, but the victories appear to have been too late for Jonathan at the ballot box.
(Additional reporting by Julia Payne, Estelle Shirbon, Chijioke Ohuocha and Bate Felix; Writing by Ed Cropley; Editing by Angus MacSwan and David Stamp)