President John Dramani Mahama has been declared the winner of Ghana's presidential election, despite widespread technical glitches with the machines used to identify voters and protests by the opposition claiming the vote was rigged.
Armoured tanks surrounded Ghana's electoral commission and police barricaded the road around the electoral offices as the body's chairman Kwadwo Afari-Gyan announced that Mr Mahama had polled 5.5 million votes, or 50.7%.
Opposition leader Nana Akufo-Addo, who lost the 2008 election by less than 1%, came in second with 5.2 million votes, or 47.7%. Voter turnout was high, with around 80% of the roughly 14 million registered voters casting ballots in Friday's presidential and parliamentary elections.
The opposition said it would contest the results.
"This situation, if allowed to go unchallenged and uncorrected, would seriously damage the essence of the electoral process and the substance of democracy in Ghana," the New Patriotic Party said in a draft statement emailed to reporters.
"To accept this result is to discredit democracy in Ghana and, in the process, distort the process of democratisation in Africa. Therefore, the New Patriotic Party cannot accept the results of the presidential election as declared by the EC (election commission) this evening."
Ghana has one of the longest traditions of democracy in Africa, but Friday's election was fraught, after biometric machines used to identify voters through their fingerprints failed to work in scores of polling stations, forcing officials to extend voting into a second day. Mr Akufo-Addo's party has accused the ruling party of using the disorder caused by the technical failure to rig the election.
Ghanaians are deeply attached to their tradition of democracy and international observers are already calling Friday's election the sixth transparent vote in the country's history.
No other country in the region has had as many free and fair votes, but analysts point out that Ghana's history and its record of democratic progress is not that different from that of nearby Mali, a nation also considered a model democracy until a coup this spring.
"We won, they are sore losers. They wanted (the electoral commission) to postpone announcement of the results and (the chairman) said there is no reason to postpone. There was no foundation for their allegations," said Mahama's presidential adviser Tony Aidoo. He added that the opposition's allegation of vote rigging "was a plan to create mayhem, and mayhem will come. ... They had such high expectations of coming back to power".