ABUJA, Nigeria — Nigerians celebrated Muhammadu Buhari’s electrifying victory in presidential elections Wednesday but sobering challenges confront their next leader, from an Islamic uprising to widespread poverty and corruption.

Buhari — a former military general who once led Nigeria following a coup — made history in Africa’s most populous country and biggest oil exporter as the first opposition party candidate to win democratic elections, ending President Goodluck Jonathan’s bid for another term.

Buhari warned the country’s Boko Haram insurgents that he’d be coming after them.

“No doubt this nation has suffered greatly in the recent past and its staying power has been challenged to its limits, chief among them the insurgency of Boko Haram,” he said Wednesday at Abuja’s international conference center where he received a certificate attesting to his victory.

“Boko Haram will soon know the strength of our will and commitment to rid this nation of terror.

… We shall spare no effort until we defeat terrorism.”

Boko Haram, whose name translates roughly as “Western education is forbidden,” aims to establish an Islamic empire in Nigeria, which is half Christian and half Muslim. The group has aligned itself with the Islamic State and killed thousands of civilians and carried out frequent kidnappings — including ones of schoolgirls — in its quest to intimidate Nigerians and control more territory.

But it has been hit hard in recent weeks by government troops and allied forces from neighboring Chad, Cameroon and Niger.

Jonathan’s term was marked by his failure to control the six-year insurgency.

The president-elect also warned that corruption would not be tolerated after he takes office May 29. As Nigeria’s leader three decades ago, he returned looted government assets. Government workers who came late to work were forced to perform squats. His regime executed drug dealers.

“Corruption attacks and seeks to destroy our national institutions and character … distorts the economy and creates a class of unjustly enriched people,” Buhari said Wednesday. “Such an illegal yet powerful force soon comes to undermine democracy because it has amassed so much money that they believe they can buy government.”

Jonathan’s party has governed since military dictatorships ended in 1999. Buhari has been trying to be president since then and this was his fourth run at the presidency. Buhari had ruled Nigeria for less than 20 months before being deposed in another coup in 1985, with another major general saying Buhari had been slow to overcome the nation’s economic problems.

Jonathan conceded with grace late Tuesday, saying “I promised the country free and fair elections. I have kept my word.”

In a continent where there have been cases in which a sitting president refused to accept defeat at the polls and violence resulted — Ivory Coast in 2011 is an example — the turn of events in Nigeria was good news that was welcomed by many Nigerians and foreign leaders alike. In the northern city of Kaduna, people clapped and cheered in the streets Wednesday.

Jonathan’s concession has defused tensions and fears of post-election violence. Some 1,000 people died and 65,000 were made homeless in riots in the Muslim north after Buhari lost to Jonathan in 2011. Results from Saturday’s election show Buhari winning votes across religious, tribal and geopolitical lines.

Because of decades of military rule this was only the eighth election in Nigeria’s history and the fifth since democracy was restored in 1999.