Ghana's opposition leader John Atta Mills was declared the winner of a closely fought presidential election run-off on Saturday, sweeping his party back to power after eight years.
Electoral officials announced the result after the last constituency to vote showed him extending his lead over his rival, Nana Akufo-Addo.
Mr Akufo-Addo congratulated Mr Atta Mills, but a spokesman said the party would challenge the result in court.
Officials say there was no evidence of vote-rigging, as alleged by both sides.
The run-off, with the last vote held in Tain constituency, was closely watched as Ghana remains a rare example of a functioning democracy in West Africa.
The ruling party had boycotted the Tain constituency vote.
Results showed Mr Mills, of the National Democratic Congress, narrowly defeated Nana Akufo-Addo of the New Patriotic Party, which lost its parliamentary majority in an election in December.
Electoral Commission chairman Kwadwo Afari-Gyan said Mr Atta Mills won 50.23% of the vote against 49.77% for Mr Akufo-Addo.
Mr Atta Mills, a former vice-president who twice lost presidential polls to outgoing NPP President John Kufuor, was conciliatory.
"I want to assure everybody that I will be president for all. There will be no discrimination," he said in a victory speech to thousands of NDC supporters who thronged the streets around his office in the capital, Accra.
"It is my hope that we will be able to work together to build a better Ghana."
Mr Akufo-Addo conceded defeat. "Our nation is at a crossroads and we must work together to build it peacefully."
International monitors say voting has been mostly peaceful. Ghana's political stability has attracted growing numbers of foreign investors as it prepares to produce oil in late 2010.
The centre-left NDC has promised change after eight years of NPP rule, though analysts say there are few policy differences.