Somalia's moderate Islamist leader Sheikh Sharif Ahmed won the presidency on Saturday and vowed to end conflict in the Horn of Africa nation, make peace with neighbours and rule with honesty and justice.

Legislators applauded, and the former geography teacher smiled and raised his arms aloft, after winning the election around 4 a.m. local time (0100) in a run-off vote during an all-night session of the Somali parliament in Djibouti.

Analysts say Ahmed has a real chance of reuniting Somalis, given his Islamist roots, backing of parliament and acceptability to the West.

But reconciling the country's 10 million people and stopping 18 years of bloodshed remain a daunting task even for him.

Ahmed headed the sharia courts movement that brought some stability to Mogadishu and most of south Somalia in 2006, before Ethiopian troops invaded and ousted them from power.

"The conflict in Somalia will be resolved. We are urging our brothers in armed conflict to join us in peace-building," he told parliament. "We will govern the Somali people with honesty and justice, and give them back their rights."

After being sworn in at a hotel in Djibouti on Saturday morning, the Islamist will fly to the very country that chased him from Somalia to attend an African leaders summit.

He then returns to Somalia to try and put together a unity government -- the 15th such attempt since Somalia descended into anarchy with the ouster of a dictator in 1991.

Legislators elected him in Djibouti due to the instability at home. But they hope they have elected a man able to isolate or even possibly bring on board hardline insurgents, even if there is a risk the violence spikes in the short term.

Despite the withdrawal of Ethiopian troops earlier this week, and the U.N.-brokered Djibouti peace process intended to reconcile the government and opposition, hardline Islamist insurgents led by al Shabaab have vowed to fight on.

Al Shabaab, which is on Washington's list of foreign terrorist groups, said just before the vote that it would start a new campaign of hit-and-run attacks on the government -- whoever came to power.

The group's spokesman, Sheikh Mukhtar Robow Mansoor, urged jihadists to make ready in comments after prayers in Baidoa, the former seat of parliament that al Shabaab overran this week.

"Sheikh Sharif and the election in Djibouti is not something to be supported," Sheikh Hassan Yacqub, al Shabaab spokesman in the southern city of Kismayu, told Reuters on Saturday.

MISINTERPRETATION OF ISLAM

Ahmed said those fighting to impose a strict version of Islamic law throughout the country had misinterpreted the religion and he would try to correct that.

He also said his government would not tolerate any abuse of power or corruption and treat neighbours with respect.

U.N. envoy to Somalia, Ahmedou Ould-Abdallah, hailed Saturday's vote and called for a spirit of reconciliation.

In the past two years, more than 16,000 civilians and an unknown number of combatants have died during an Islamist-led insurgency against the government and its Ethiopian allies.

One million people have been driven from their homes, and a third of the population relies on food aid in what aid agencies call one of the world's worst humanitarian crises.

Under Somalia's complicated clan system, Ahmed, a Hawiye, will now seek to appoint a Darod prime minister to ensure representation of the major groups.

Many Somalis doubted that Ahmed's election would bring peace, saying the armed threat from hardliners remained, and an election brokered abroad may lack legitimacy in the eyes of some.

"Sheikh Sharif will face a security challenge from al Shabaab. These chaotic Islamists will take no heed of his election. He will never tackle Somalia's crisis unless he is fully supported by the international community," a Mogadishu local elder, Abdiqadir Farah, told Reuters.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.