Somalia's parliament elected a moderate Islamist leader as the country's new president early on Saturday, handing over the elusive task of stabilizing a country wracked by violence and anarchy for nearly 20 years.
Sheik Sharif Sheik Ahmed was elected in neighboring Djibouti after the last president _ a former soldier, rebel and warlord named Abdullahi Yusuf _ resigned in December after failing to pacify the country during his four-years as president.
Ahmed was chairman of the Islamic Courts Union that ran Mogadishu for six months in 2006 before Ethiopian soldiers drove them from power. His election raises hopes that he will bring many of Somalia's Islamic factions into a more inclusive government. But the Western-backed government wields little control in Somalia _ just a few blocks of the capital, Mogadishu, where African Union peacekeepers patrol. An Islamic insurgent group called al-Shabab, who say they don't recognize the government, have taken over most of Somalia.
The US considers al-Shabab a terror organization with links to al-Qaida.
Somalia's parliament has been meeting all week in neighboring Djibouti to choose the new president. Sharif won easily with 293 votes after the other front-runner, the prime minister, withdrew. The second-place candidate received 126 votes.
Sharif was due to be sworn in later on Saturday, then fly to the Ethiopian capital for an African Union summit.
The arid and impoverished Horn of Africa nation of some 8 million people has not had a functioning government for a generation, since clan-based militias overthrew the a dictator in 1991 then turned on each other.
Pirates prey on international shipping freely from Somalia's lawless shores, and analysts fear an extremist Islamic administration could become a haven for international terrorists. There have been more than a dozen previous peace efforts and three previous governments were formed, but they never managed to take effective control over most of the country.