By Patrick McGroarty in Lagos, Nigeria, and Heidi Vogt in Yola, Nigeria 

Former military dictator Muhammadu Buhari built a wide lead in Nigeria's elections on Monday, raising the prospect of a 1980s-era strongman being elected to lead the emerging but troubled country.

Such an upset in this nation of 170 million would be a stinging rebuke to a ruling party many voters said failed to tackle corruption and allowed a deadly insurgency to take root in Africa's top economy.

Results from 19 of Nigeria's 37 federal territories showed the 72-year-old Mr. Buhari with 56% of about 15.6 million votes cast, compared with 43% for incumbent President Goodluck Jonathan. Results from the remaining states were expected Tuesday.

The winner will have to try to revive an economy hit hard by the crumbling price of oil, Nigeria's main export and source of government revenue. Fitch Ratings put Nigeria's government debt on negative outlook on Monday, a sign a downgrade could be imminent. Standard & Poor's Ratings Services downgraded Nigeria's debt this month.

"It's been growth without development," said E. Chike Nwanze, chief executive of Icon Stockbrokers, who was scribbling his own tally on a sheet of paper at his office in a Lagos office tower.

Mr. Buhari, who led the country for 20 months after a 1983 coup, has pledged to plug budget holes by tackling corruption. Mr. Jonathan, a 57-year-old former zoology professor, says he will cut spending to protect the government's balance sheet.

Economists say either approach would collide with Nigeria's entrenched political class and face long odds.

"Anybody who decides to do the budget slashing that needs to be done to address Nigeria's economic crisis is pretty much setting fire to a powder keg," said Manji Cheto, an analyst at Teneo Intelligence.

Mr. Nwanze helped run a Nigerian bank in the 1980s when Mr. Buhari led a military regime, and he voted for Mr. Buhari over the weekend.

He remembers successes, like oil refineries that have fallen into disrepair, and misfires like swapping oil for imports such as milk and rice instead of equipment to build roads and factories. But above all, he said, "Buhari leads a frugal life, a principled one."

Mr. Jonathan, seeking a second four-year term, has banked on states in his southern and predominantly Christian stronghold

"He needs more time to bring more change across the country," said Obi Feanyichuwku, a biochemistry student in Mr. Jonathan's hometown of Otuoke.

Some analysts said they thought victory was now beyond Mr. Jonathan's grasp. Charles Robertson, chief economist at Renaissance Capital, said based on the partial results, Mr. Buhari looked set to beat Mr. Jonathan by about three million votes, winning 55% of the vote.

A winner must secure both a majority and 25% of the vote in two-thirds of Nigeria's states. Both candidates have pledged to respect the results, if they are deemed credible.

More than 50 million people were accredited to vote in Nigeria's chaotic and occasionally violent elections this weekend. The vote was extended to Sunday after the failure of some new voter-identification equipment.

Although election observers were mostly positive about the vote despite technical problems, the U.S. and U.K. on Monday warned of efforts to manipulate the results, the latest troubling sign in a country with a history of postelection violence.

"There are disturbing indications that the collation process--where the votes are finally counted--may be subject to deliberate political interference," U.S. Secretary of State John Kerry and U.K. Foreign Secretary Philip Hammond said, without detailing their concerns.

Nigerian Election Commission Chairman Attahiru Jega on Sunday said he was under the influence of no party to doctor the results. "I'm not pressured by anybody."

Millions of people waited to cast ballots on Saturday, but many also grew frustrated after the breakdown of new electronic scanners meant to prevent ballot-stuffing by verifying each voter's identification card and fingerprint.

Nigeria's electoral commission acknowledged some of the devices had failed. In some places, poll workers didn't know to remove the plastic film guarding the fingerprint-reading screen, officials said. Three machines failed to read Mr. Jonathan's fingerprints.

The commission reopened voting at about 350 polling stations on Sunday--a fraction of more than 120,000 voting outposts across the country.

Election observers generally struck an upbeat note.

"Despite widespread problems on Election Day, Nigerians showed perseverance, creativity and discipline," the Washington-based National Democratic Institute, an observer group, said on Monday. "No significant disenfranchisement was observed."

Some Nigerians didn't agree. In oil-rich Rivers State, thousands of people rallied on Sunday behind Gov. Rotimi Amaechi's calls for the state's vote to be canceled. An architect of Mr. Buhari's campaign, Gov. Amaechi said the vote there was marred by dysfunctional polling stations and intimidation from security forces that prevented many people from casting ballots.

Mr. Jega, the election commission chairman, acknowledged problems there. "We saw lapses more than we envisaged." Results from Rivers State weren't reported on Monday.

Election observers said problems in Rivers State weren't widespread enough to undermine the credibility of the broader result. "These issues did not systematically disadvantage any candidate or party," said Zik Ibrahim, chairman of Nigeria's Transition Monitoring Group.

But simmering anger in the Niger Delta could become a flash point for the violence that has marred past elections. Mr. Jonathan's 2011 victory over Mr. Buhari touched off clashes that left more than 800 people dead, according to Human Rights Watch.

The Islamist insurgency Boko Haram also made its menace felt on voting day. Officials pushed back the election by six weeks to drive the militant group out of communities across the impoverished and isolated northeast.

That campaign appears to have been successful, thanks in part to the support of troops from neighboring Chad and Niger.

Yet suspected Boko Haram gunmen stormed polling stations in two districts of northeastern Bauchi state on Sunday, destroying electoral materials and sending residents fleeing, said state police spokesman Haruna Mohammed.

On Saturday, militants killed more than 40 people in the northeastern states of Borno and Gombe.

In Yola, a city at the southern edge of the vast arid region Boko Haram has terrorized, people said they hoped Mr. Buhari might be able to restore order in ways big and small.

The retired general in his time in office purged corrupt officials before being overthrown by his soldiers.

During his tenure, he waged what he called a War Against Indiscipline. Police whipped people who were late to work or cut in line.

Mohammed Abbas, 59, a retired banker, said he remembered how things changed even at his own bank when Mr. Buhari took power in the 1980s.

"He said everybody should stand in line," Mr. Abbas said. "And then they stood in line."

Gbenga Akingbule in Abuja, Nigeria, contributed to this article.

Write to Patrick McGroarty at patrick.mcgroarty@wsj.com and Heidi Vogt at heidi.vogt@wsj.com