MONROVIA, Liberia — For decades, Liberia has waited through war and strongmen for a peaceful democratic transfer of power. On Thursday, as the last ballots in a presidential election were being tallied, that appeared to be on the verge of happening.

Unofficial elections returns showed that George Weah, a former international soccer star, defeated the sitting vice president, two former warlords and his own ex-girlfriend and won the right to succeed the first woman democratically elected as president of an African country.

It was Mr. Weah’s third bid to lead Liberia, a nation founded almost two centuries ago by freed American blacks. He will succeed Ellen Johnson Sirleaf.

In electing Mr. Weah, Liberian voters are investing in him hopes that he can build on one certain accomplishment of Mrs. Sirleaf: keeping the country out of war. But Mrs. Sirleaf’s government has also been plagued with corruption charges, high unemployment and a shambolic health system that is still trying to regain its footing after the devastation of the 2014 Ebola epidemic, which killed more people in Liberia than anywhere else.

Mr. Weah, 51, will take over the running of Liberia without Mrs. Sirleaf’s long history of public service. His only experience in government office has been his three years as a senator, representing Monrovia, a time during which his opponents criticized him for failing to speak up during legislative sessions.

Unlike Mrs. Sirleaf, who came to power in 2005 after 35 years on the global scene, Mr. Weah will not be able to call on an international network of allies to help. When Mrs. Sirleaf was trying to rescue the Liberian economy, she got her country’s $4.7 billion debt erased. When her country’s health system needed help fighting Ebola, Mrs. Sirleaf got President Barack Obama to send 3,000 American troops to Liberia.

Mr. Weah’s global contacts are primarily in the international soccer world, and he recently credited Arsène Wenger, coach of the English powerhouse Arsenal Football Club, with mentoring him when he was a soccer player in Europe. Whether Mr. Weah can use his sporting credentials to help build roads and schools and bring back jobs will be among his biggest challenges. It also remains to be seen whether he will continue to allow the level of freedom of speech that has characterized Mrs. Sirleaf’s tenure.

But Mr. Weah successfully navigated his latest campaign to become president. In the weeks leading up to the runoff presidential election on Tuesday, Mr. Weah’s opponent, Vice President Joseph Boakai, accused President Sirleaf of secretly orchestrating his defeat. The vice president went all the way to the Liberian Supreme Court with his charges and managed to delay the final runoff election by two months.

Mr. Weah responded by stepping back, keeping his supporters off the streets and remaining quiet as the drama unfolded around him.

The runoff, originally set for October, was finally scheduled for the day after Christmas. That is a day when many voters might be expected to be recuperating at home after the holiday — and the result was as many people expected. Voter turnout was low. It was a last-gasp effort by the vice president’s forces to save him from defeat, critics in Monrovia said. But in the end it did not work.

Liberia’s National Elections Commission announced on Thursday that Mr. Weah, with 98 percent of votes counted, was beating Mr. Boakai handily. Mr. Weah had 61.5 percent of the more than one million votes tallied, while Mr. Boakai had 38.5 percent, the commission announced.

The elections commission stopped short of declaring Mr. Weah the outright winner at a news conference on Thursday, with officials saying they would have final results soon. But at Mr. Weah’s Congress for Democratic Change Party headquarters, hundreds of people with crackling radios held to their ears erupted over the results.

In Gibraltar, the Monrovia neighborhood where Mr. Weah grew up, residents on Thursday spoke about how their slum was now a “president’s community.”

“People can classify our community, saying that’s so-so gronah people living here, and today this community is coming to produce a president,” said Veronica Doe, 46, using a Liberian-English reference to street boys.

Ms. Doe, a mother of seven, said she had played kickball on the same dusty soccer field as Mr. Weah in the 1980s. Now she sells small plastic bags of water out of a cooler, one of the thousands of market women who drive the local economy.

Next to her stall, a narrow alleyway edged by concertina wire led to the modest house where Mr. Weah was raised by his grandmother, which is now occupied by other tenants. Women sold charcoal, biscuits and bread on the stoop and children ran around.

Mr. Weah’s is a rags-to-riches story. He emerged from the slums of Gibraltar with an uncanny ability to weave behind a soccer ball all the way up the pitch, and eventually gained fame as a world-class striker for the Italian team A.C. Milan. He won the soccer world’s greatest individual honor, the Ballon d’Or, and was named by FIFA, soccer’s governing body, as the African Player of the Century.

He never got to compete in the World Cup, because Liberia was engulfed by civil war, instigated by President Charles Taylor, during the height of Mr. Weah’s soccer years and was unable to muster up 10 other players good enough to qualify.

Mr. Taylor is now locked up in a British prison for war crimes. But in the surreal world of Liberian politics, Mr. Weah’s running mate, who will now presumably be his vice president, was Mr. Taylor’s ex-wife, Jewel Howard Taylor.

Ms. Taylor caused a stir early in the election campaign when she told reporters that although her ex-husband was no longer involved in Liberian politics, he still had promises that needed to be kept. She called for putting Mr. Taylor’s agenda “back on the table.”

The resulting uproar led Mr. Weah’s party to muzzle Ms. Taylor, and she became more circumspect on the campaign trail.

Mr. Weah, meanwhile, was running against an ex-girlfriend, a model turned philanthropist named MacDella Cooper who says he is the father of her third child.

But his behavior during his third election bid converted many former skeptics. In his first two campaigns, which he lost to Mrs. Sirleaf, Mr. Weah’s youthful supporters were criticized for threatening their opponents with violence. Many young men who supported him went through the streets of Monrovia, chanting “No Weah, No Peace,” and getting into fights.

For 43 days in 2005, Mr. Weah himself protested Mrs. Sirleaf’s election. It was only under heavy pressure from the international community and local authorities, who dismissed his allegations of fraud, that he finally accepted the election results to “allow peace,” he said, in Liberia.

This time around, with Mr. Boakai claiming that Mr. Weah’s lead in the polls was a result of fraud, the candidate took the high road. His youthful supporters stayed off the streets. Even when the runoff election was delayed by Mr. Boakai’s complaints, Mr. Weah’s supporters stuck with the electoral process.

On Thursday, they were reaping the rewards. Richard M. Nahas, 20, a Weah supporter, said he had high expectations of Mr. Weah.

“I want him to bring job opportunities and to build the economy of the country — that’s the main thing now we need,” said Mr. Nahas, dressed in a yellow Cameroon national team soccer jersey.

Clair MacDougall reported from Monrovia, and Helene Cooper from Washington.

The AfricaPaper: Our sincere thanks to The New York Times for this story