President John Atta Mills, who won international praise for presiding over a stable model democracy in Africa, died suddenly on Tuesday after celebrating his 68th birthday on Saturday. His unexpected death came months before he was due to stand for re-election in December as head of the world's number two cocoa grower, which is also a major African gold producer.
Mahama's swift inauguration underscored Ghana's stability in a part of the world where the deaths of other leaders have sparked coups.
"It is with a heavy heart … that we announce the sudden and untimely death of the president of the Republic of Ghana," the president's office said. It added that Mills had died a few hours after being taken ill, but gave no further details.
A presidential aide, who asked not to be named, said the president had complained of pains on Monday evening and had died early on Tuesday afternoon when his condition worsened.
In line with Ghana's Constitution, Mahama, who is 53, took the oath of office as head of state before a sombre Parliament hours after the announcement of Mills's death. Mahama will serve as caretaker president until the elections at the end of the year.
Analysts hailed this as a sign that the country's political institutions were solid and working smoothly.
"With Ghana's reputation for stability, having seen two peaceful transitions in government following elections in 2000 and 2008, the strength of Ghana's institutions are likely to see the country in good stead," said Razia Khan, head of Africa research at Standard Chartered.
"As such, market volatility related to near-term uncertainty is likely to be limited," she added.
The people's man
On the streets of Cape Coast, kilometres from Accra, people held radios to their ears on the street, listening to the funeral hymns playing on FM stations and waiting for more information about the president's unexpected death.
"His speeches were full of a spirit of love and peace," said Efua Mensima (45). "He was soft-spoken. I wept when I heard of his death."
In a predominantly Ghanaian section of Ivory Coast's commercial capital, a group of 10 men tried to organise a bus to take them to Ghana for the president's funeral.
"The Ghanaian people were happy with this president and his program for the development of the country," said Nour Ousmane Aladji (27), a taxi driver who moved to Abidjan in 2000.
Amid swirling rumours about his ill health, Mills had returned from medical checks in the United States a few weeks ago. Some reports by local newspapers speculated he had throat cancer, other reports mentioned a sinus-related affliction.
Ghana's election commission said December's presidential and parliamentary elections would go ahead as planned.
Obama pays tribute
Some analysts questioned whether Mills's death might open up a presidential candidacy battle inside the ruling National Democratic Congress party before the elections. The party will hold an emergency congress to elect a new presidential candidate to contest the vote.
"Elections will have to be held soon and one does not know what the new president will decide, in particular in terms of resource nationalism. Elections are always a factor of instability in Africa," said Martin Bauwens, managing director of Johannesburg-based mine consultancy MJB Consulting.
Producers in Africa's second largest gold producer have raised concerns about government moves to raise the corporate mining tax to 35% from 25% and to introduce a 10% windfall tax as well.
Ghana's state and private radio and TV channels suspended regular programming and played patriotic songs between messages of condolence, urging Ghanaians to unite in a time of grief.
US President Barack Obama, who had received Mills in the Oval Office in March and praised him and his country as "a good-news story" in Africa, also sent his condolences.
"He helped promote economic growth in Ghana in the midst of challenging global circumstances and strengthened Ghana's strong tradition of democracy … He was also a strong advocate for human rights and for the fair treatment of all Ghanaians," Obama said in a statement from the White House.
UN secretary general Ban Ki-moon said "President Mills will be remembered for his statesmanship and years of dedicated service to his country," according to a statement from his spokesperson.
"At this time of national mourning, the secretary general renews the commitment of the United Nations to work alongside the government and the people of Ghana in support of their efforts to consolidate the country's democratic and development achievements," the spokesperson said.
Trained as a lawyer and taxation expert, Mills had overseen Ghana's emergence as one of Africa's newest oil producers two years ago, earning respect at home and abroad for his economic policies and commitment to democracy and good governance.
Ghana has seen democratic elections decide its leadership no fewer than four times since the last military coup in 1981, a rare feat in a region where power is still just as often determined by the bullet as by the ballot.
The new caretaker president, Mahama, has just published a book entitled My First Coup d'Etat: And Other True Stories from the Lost Decades of Africa, a memoir of his early years in the often turbulent events that followed Ghana's 1957 independence from Britain. – Reuters, Sapa-AP