Mogadishu (AFP) - Former Somali prime minister Mohamed Abdullahi Mohamed, who holds joint American citizenship, was elected president on Wednesday, vowing to crack down on corruption and Al-Shabaab militants.

The 55-year-old former premier, whose hails from the Darod clan and who 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.

Story continues

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.

- Limited vote -

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.

- 'Most expensive election' -

If Farmajo is serious about cracking down on corruption, he has his work cut out for him in a country listed as the most corrupt in the world by Transparency International.

Mogadishu-based anti-corruption NGO Marqaati in a report released this week described rampant vote-buying, and alleged that civil servants had gone unpaid for seven months and public lands sold off to fund lobbying for MP positions.

"When delegates refused to take money and vote a certain way, they would be replaced, intimidated, harassed and, in some incidences... shot," read the report.

The report said some delegates were paid up to $30,000 each to vote for MPs, while presidential candidates seeking to sway MP votes were reported to have to fork out $50,000 to $100,000 per lawmaker.

"The electoral process has been subject to serious allegations of fraud and corruption, some of them clearly substantiated," UN spokesman Stephane Dujarric said.

The US State Department said that it regretted "numerous credible reports of irregularities in the electoral process", but that it would work with Farmajo "to advance reconciliation, drought relief, security, and build the strong institutions to deliver good governance and development for the Somali people."

Francisco Caetano Madeira, chair of the African Union Mission for Somalia, which has been helping the country to combat the Shabaab, also urged the new administration "to use the next four years in office to enhance reconciliation and unity".