Somalia's new President, Mohamed Abdullahi, has been inaugurated in the capital Mogadishu, promising to restore dignity to the troubled Horn of Africa nation but warning it will take another two decades to "fix" the country.

"Multiple challenges are ahead of our government. Therefore, I am telling people that because of the limited resources we have, our achievements will be limited," said Mohamed, also known as Farmajo, on Wednesday at the ceremony.

"For the past 26 years there have been conflicts and droughts, so it will take other 20 years to fix this country."

The dual US-Somali citizen and former prime minister was sworn in at a ceremony held in the highly secured airport zone to avoid an attack by the al-Qaeda-linked al-Shabab group, which has threatened a "vicious war" against the new government.

All major roads and streets inside and outside the capital were blocked and commercial flights were cancelled for security reasons.

Farmajo has already taken office following a handover ceremony last week during which al-Shabab fighters fired mortar shells near the presidential palace, killing two children at a nearby school.

In a sign of the challenges facing his administration, a car bomb at a busy market killed 39 people on Sunday.

His election was met with elation among Somalis, who fondly remember his brief stint as prime minister in 2010-11 which showed him to be a no-nonsense leader set on improving governance and cracking down on corruption.

Somalia in crisis

Almost 1.4 million children suffering from severe malnutrition could die this year as famine looms in Nigeria, Somalia and Yemen, the UN children's agency said on Monday.

The warning comes a day after government officials and the United Nations declared famine in parts of South Sudan.

Al Jazeera's Catherine Soi, reporting from Mogadishu, said people expect the new president to address security threats and how to deal with the UN's warning that a severe drought has placed large swaths of the country at risk of famine.

"People are eager to know who is going to be his Prime Minister and who is going to be in his cabinet. A president is only as good is the people he surrounds himself with," she said.

"In the former government, there was a lot of infighting so people are hoping that Farmajo is not going to make that mistake and will select people who are in-lined with his vision and who will help him move this country forward."

Somalia's limited election process, in which only several thousand delegates voted for politicians, is seen as a step towards full democracy for the country, which has not had an effective central government since the collapse of Siad Barre's military regime in 1991, which led to civil war and decades of anarchy.

African Union troops drove al-Shabab fighters out of Mogadishu in August 2011 but the armed group continue to control rural areas and launch repeated attacks in the capital.