Mohamed Abdullahi Mohamed (C) holds dual Somali-US citizenship, pledged to crackdown on corruption and al-Shabaab militants. Photograph: (AFP)
Popularly known as Farmajo, he had 184 votes to incumbent president Hassan Sheikh Mohamud's 97 votes. Mohamud then decided to drop out
Former Somali prime minister Mohamed Abdullahi Mohamed, who holds dual Somali-US citizenship, was elected president on Wednesday, vowing to crack down on corruption and Al-Shabaab militants.
The 55-year-old former premier, who hails from the Darod clan and goes by the nickname "Farmajo", won after incumbent president Hassan Sheikh Mohamud acknowledged defeat in a second round of voting by lawmakers.
"This is the beginning of unity for the Somali nation, the beginning of the fight against Shabaab and corruption", a triumphant Farmajo said after being declared the winner in a long, drawn-out election process in the conflict-wracked nation.
Civilians took to the streets and soldiers fired celebratory gunfire in the capital Mogadishu which had been near-deserted for two days with roads and schools closed and residents urged to stay indoors for fear of a strike on the capital by Shabaab militants.
And Somali refugees in Dadaab, the world's biggest refugee camp in eastern Kenya, also erupted with joy and sang the national anthem when hearing Farmajo had won, according to an AFP correspondent.
"Time has come for us Somalis. I thank God. This is the man we need, he cares for us, he cares for the poor men and women," said 60-year-old Anfi Kassim who has lived in the camp since 1992.
The United States said it regretted the numerous reports of electoral fraud, but urged Farmajo to use his new mandate to "deliver good governance" to the needy Horn of Africa state.
After six hours and two rounds of voting, a crowded field of 21 presidential candidates was whittled down to the two veteran politicians.
Farmajo failed to win the required two-thirds majority, but had 184 votes to Mohamud's 97, prompting the incumbent to drop out to avoid a third round.
The father of four served as prime minister for only eight months between 2010 and 2011 and was ousted in a deal to form a new government and postpone elections that year.
However several of his moves, such as implementing regular payments of soldiers, were well received and many supporters took to the streets of Mogadishu to protest his removal.
Farmajo was born in the capital to a family from the southern Gedo region and moved to the United States where he studied history and political science at the University of Buffalo.
He went on to work in the foreign ministry and as a diplomat in Washington before the collapse of Siad Barre's military regime in 1991 which led to civil war and decades of anarchy in Somalia.
Farmajo also ran for president in 2012, in the first election inside the country since 1991. In that election, only 135 clan elders picked the lawmakers who went on to elect the president.
In 2016 Somalia had been promised a one-person, one-vote election. However political infighting and insecurity saw the plan ditched for a limited vote running six months behind schedule.
Although the election is billed as its most democratic in nearly five decades, only 14,000 delegates were able to vote for the lawmakers who went on to elect the president.
The long, drawn-out election has largely consisted of horsetrading between different clans, with widespread allegations of vote-buying and corruption, leaving it a distant process to the average Somali.
The internationally-backed government still has limited control over a country where swathes of countryside are controlled by Al-Qaeda-linked Al-Shabaab militants who regularly launch deadly strikes against Mogadishu.