In an election that became a referendum on Ghana’s faltering economy, Nana Akufo-Addo, a leader of the opposition, surfaced Friday as the winner over the incumbent president, John Mahama.
Mr. Akufo-Addo, a lawyer and former foreign minister, rode a wave of popular discontent at a time when the growth rate has plummeted along with oil and commodity prices.
The West African country, which produces oil, gold and cocoa, has endured a currency crisis, electricity shortages, and took a $918 million bailout from the International Monetary Fund last year in the face of mounting debt.
The weight of those economic woes proved an insurmountable hurdle for Mr. Mahama, who ascended from the vice presidency in 2012 following the death of his predecessor, John Atta Mills.
Mr. Akufo-Addo won 53.9 percent of the roughly 11 million votes cast compared with 44.4 percent for Mr. Mahama, Ghana’s electoral commission announced Friday night.
Supporters who had gathered for hours at Mr. Akufo-Addo’s compound in the center of Accra, the capital, erupted in ecstasy at the news that Mr. Mahama had called his rival to concede defeat.
“I make this solemn pledge to you tonight: I will not let you down,” Mr. Akufo-Addo, 72, said as he addressed the nation from the compound against a backdrop of fireworks and bullhorns.
Crowds swarmed the streets of Accra, yelling out of car windows, embracing and dancing.
The hard-fought election mirrored the 2012 contest between the same two men, in which Mr. Mahama narrowly defeated Mr. Akufo-Addo, a victory that was challenged but upheld by Ghana’s Supreme Court.
This time, Mr. Akufo-Addo’s New Patriotic Party tapped into the economic anxieties that had been building in Ghanaians and effectively laid the blame for them on Mr. Mahama’s National Democratic Congress.
Ghana’s growth rate had dropped from a surging 14 percent in 2011 to 3.9 percent last year as commodity prices fell.
“The 2016 result actually has its roots in the 2012 election,” said Philip Walker, an analyst at The Economist Intelligence Unit. “Back then a government spending spree in pursuit of re-election saw the fiscal deficit balloon, inflation surge and the currency plunge.”
Many Ghanaians went to the polls to reaffirm their reputation as a model African democracy on a continent often associated with violent or stolen elections. Some lined up before dawn on Wednesday to cast their ballots. Others huddled around radios in the dimly lit streets of Accra on Wednesday night, listening as election officials hoarsely read results polling station by polling station.
The wait for results to come in dragged on, and pressure mounted on the electoral commission to speed up the counting process throughout Friday. The African Union had called on the commission “to expedite announcement of remaining results in order to address the growing anxiety caused by the delay.”
Election observers praised Ghana for what they generally deemed to be a transparent and fair contest.
Abdullai Salifu, a 29-year-old salesman who came to Mr. Akufo-Addo’s compound, said he would be celebrating on the streets of Accra all night. “This is the moment we have been waiting for” for years, Mr. Salifu said with a broad smile.