Tens of thousands of people in the Ghanaian capital Accra have attended the state funeral for President John Atta Mills, who died suddenly in July.
Some 18 African heads of state and US Secretary of State Hillary Clinton witnessed the ceremony in Accra's Independence Square.
Mills, who had long suffered from throat cancer, died only five months before he was set to seek re-election.
A BBC reporter in Accra says his death has united Ghanaians in grief.
She says his death was seen as a test for the country's young democracy.
Mills, who started a four-year term in January 2009, was succeeded by Vice-President John Dramani Mahama.
Ghana has won international plaudits for the swift manner in which it handled the transition in a nation known for its divisive politics.
"Today a dark cloud hangs over Ghana, over Africa and indeed over the entire world," Mr Mahama told the thousands of mourners who were able to watch the proceedings on large television screens set up around the square.
"President Mills was the very embodiment of what has been missing from our politics - civility, humility in service, honesty," he said.
The BBC's Vera Kwakofi says people began gathering before dawn in and around Independence Square, dressed in the official colours of mourning - black and red.
Most of the traditional chiefs attended along with their own drummers who pounded out personal messages of grief, she says.
In front of the drummers, dancers performed - the twisting of their hands and arms all had symbolic meanings.
When the military band and cortege carrying the coffin entered the square, the drumming, praise singing and warrior songs stopped, our reporter says.
Mournful flutes played while President Mahama lit the perpetual flame of remembrance for the late president, who was often referred to as "The Prof" - a reference to his long academic career - and "Asumdwoehene", meaning prince of peace in the Twi language.
Queuing for hours
The president's body has been taken for burial in a bird sanctuary next to the seat of government, the 17th-century Fort Christiansborg, also known as Osu Castle, which overlooks the Atlantic Ocean.
Over the past two days, thousands of Ghanaians have streamed into Accra to pay their last respects to Mills as he lay in state.
Some mourners queued for hours, many of them wailing with grief, in lines up to 10km (6 miles) long outside the State House in Accra.
"I've been here for about three hours, just to see him, but we're really going to miss him so much here," one woman told the BBC.
Mrs Clinton arrived from Nigeria on Thursday to attend the funeral, on the last stop of her 11-day, seven-nation tour of Africa.
She has held talks with President Mahama.
Seen as a bastion of democracy in an often turbulent region, Ghana was chosen by Barack Obama for his first visit to sub-Saharan Africa as US president in 2009.
Mills, who died aged 68, was a senior political figure for many years.
Between 1997-2001 he served as vice-president to former military ruler Jerry Rawlings, but distanced himself from his former boss.
He came to power after narrowly winning against a candidate from the then governing New Patriotic Party, Nana Akufo-Addo, in polls in December 2008.