Ghana’s new President John Dramani Mahama has pledged to uphold stability following the death of his predecessor John Atta Mills.
Mr Mahama, 53, was sworn in several hours after the 68-year-old president died at a hospital in the capital, Accra.
The opposition has praised the swift transition to Mr Mahama, saying it showed Ghana was a mature democracy.
Mr Atta Mills, who suffered from throat cancer, had governed since 2009.
He had planned to run for a second term in elections in December.
The BBC’s Sammy Darko, in Accra, says Mr Mahama will now serve as president until the election, but it is unclear whether he will be the candidate of the governing National Democratic Congress (NDC) party.
Taking the oath at an emergency parliamentary session, Mr Mahama said he would govern for all Ghanaians.
“I wish Ghanaians to be assured that all is well,” Mr Mahama said.
Smooth handover
“We are going to maintain the peace, unity and stability that Ghana is noted for.”
Mr Mahama has declared a week of national mourning.
Opposition New Patriotic Party (NNP) presidential candidate Nana Akufo-Addo has suspended campaigning out of respect for Mr Atta Mills, our reporter says.
NPP chairman Jake Obetsebi-Lamptey praised the smooth transfer of power that happened within hours of the president’s death.
“Ghana actually has handled itself very well. We have never been through this before,” he said.
“Yet the transition that we saw in parliament has been very well handled, very smooth. We are showing a maturity that must encourage all Ghanaians.”
Mr Atta Mills died a few hours after being taken ill. No details have been given.
While Mr Atta Mills’s illness had always been a subject of great debate, it was never officially confirmed, correspondents say. He had always insisted he was well, and planned to seek re-election in December’s poll.
According to a presidential aide, the leader had complained of pains on Monday evening and his condition had deteriorated.
He had recently returned to Ghana after visiting the US for medical checks.
Elizabeth Ohene, a journalist and former government minister, told the BBC’s Focus on Africa programme that “for the past three or four years there’s been news he’s been unwell and rumours of his death – twice – and he appeared with grim humour to say they were exaggerated, insisting he was well”.
Liberia’s President Ellen Johnson-Sirleaf extended her condolences to Ghanaians, saying the news had come as a surprise.
“On a personal level his moderation and integrity stood out,” Mrs Johnson-Sirleaf said, adding that Mr Atta Mills had played a strong role at the regional meetings they both attended.
US President Barack Obama also paid tribute, praising Mr Atta Mills as a “strong advocate for human rights and for the fair treatment of all Ghanaians”, according to a White House statement.
Mr Atta Mills served as vice-president to former Ghanaian military ruler Jerry Rawlings between 1997 and January 2001.
He came to power after narrowly winning against Mr Akufo-Addo, in polls in December 2008.
His predecessor, John Kufuor, stepped down after having served the maximum permitted two four-year terms.
Under Mr Atta Mills’ leadership, Ghana joined the ranks of the world’s large-scale oil producers.