Nigeria’s president-elect Buhari vows to target Boko Haram. (Reuters)

When the next president of Nigeria, Muhammadu Buhari, is asked how he will defeat Boko Haram militants who have terrorized this country, he is quick to remind people of his previous career.

As a young man, Buhari rose through the ranks of the Nigerian military, fighting pockets of insurgents in the country’s north and repelling an incursion by Chadian troops in 1983. He later served as a military dictator for more than a year.

That was 30 years ago — before democracy came to Nigeria and before the security forces were gutted by leaders who fired top-ranking officers suspected of ties to previous regimes.

Can a 72-year-old retired general wage a modern counterinsurgency campaign against Islamist militants who have ravaged northern Nigeria for years?

That is the question that many here are asking in the wake of Buhari’s historic victory in Saturday’s election — the first time an opposition candidate has defeated a sitting president in Nigeria’s 16 years as a democracy.

“There is no doubt that in tackling the insurgency, we have a tough and urgent job to do,” Buhari said in his acceptance speech Wednesday, after electoral results were announced. “But I assure you that Boko Haram will soon know the strength of our collective will and commitment to rid this nation of terror and bring back peace and normalcy to all the affected areas.”

More than 10,000 people have been killed in violence involving Boko Haram in recent years. Though the insurgency has been weakened in the past few weeks by a multinational counteroffensive, many of its key leaders are probably still alive and hiding in Nigeria’s Sambisa Forest and other rural enclaves.

“In the past, we’ve gained ground against them only to lose it,” said Abu Bakar Muazu, a prominent Nigerian security consultant. “Without continued operations, space will open up for the insurgents once again.”

Although Buhari hasn’t led a military campaign for three decades, he has maintained close relationships in the security forces. His campaign advisers include men who were recently top military brass. When Buhari’s victory was announced Tuesday night, among those dancing in the streets were groups of young soldiers.

“They still consider Buhari one of them,” said retired Col. Hussaini Monguno, who now serves as a counterterrorism adviser to the government of Borno State, the birthplace of Boko Haram.

Monguno was a military intelligence officer under Buhari in the mid-1980s and remembers a professional army that was pursuing drug traffickers and attempting to prevent cross-border incursions. But soldiers also were deeply involved in politics.

“You have to remember, this was a time when there were coups every few years,” Monguno said.

Nigerian president-elect Buhari, right, will need to reform the military, says Darren Kew, a professor at the University of Massachusetts at Boston. (-/Agence France-Presse via Getty Images)

Buhari has tried to distance himself from the armed force’s role in protecting his regime, which lasted from 1984 to 1985. For now, his military policy appears wholly focused on defeating Boko Haram.

But to do that, he will have to rebuild a military in disrepair. Boko Haram has gotten many of its weapons from Nigerian soldiers fleeing its attacks and from military bases the group has raided. The government has detained dozens of soldiers for desertion, even though many of them claimed to have fled only after their units were overpowered.

“Buhari is going to have to clean things up. The military needs to be reformed from inside,” said Darren Kew, a professor at the University of Massachusetts at Boston.

Buhari’s ability to weaken Boko Haram may depend on more than his military background. As a Muslim, he may be in a better position than his ­predecessor, President Goodluck Jonathan, a Christian, to appeal to insurgents and launch de-radicalization efforts targeting would-be fighters.

In northeastern Nigeria, Boko Haram’s success at recruitment was in part a product of government neglect and the poor economy. If Buhari focuses on economic development in the region of his birth, that could keep some men off the battlefield. In 2012, when it appeared Boko Haram was open to negotiating an end to its rebellion, the group named Buhari as one of six men it wanted to mediate talks (though Buhari refused).

“The fact that he is a northern Muslim matters a lot, because fence-sitters in the [Boko Haram] movement might be drawn away if they have more confidence in a Buhari regime,” Kew said.

During much of Buhari’s time in the military, foreign troops provided training and weapons to Nigeria. That support faded, both because of Jonathan’s apparent lack of interest and because the United States and other nations had concerns about supporting a military plagued by corruption and known for human rights abuses.

Buhari’s victory raises the possibility that more U.S. military aid could begin to flow, if reforms are made.

On Wednesday, President Obama congratulated Buhari, saying in a statement that the election has “shown the world the strength” of Nigeria’s commitment to democracy.

“This is a big opportunity for us,” said Monguno, the former military officer. “We can’t miss it.”