Somalia took a halting step toward stability Wednesday by electing a new president, a 55-year-old former prime minister who lived in the United States for many years and is a U.S. citizen.
Mohamed Abdullahi Farmaajo was voted into office by the parliament, which gathered at the Mogadishu airport because it was deemed the most secure place in a capital plagued by suicide bombings and armed attacks by the Islamic militant group Shabab.
The voting was streamed live online, and celebratory gunfire rang out in Mogadishu as Farmaajo moved ahead. After the result was announced, crowds surged into the street chanting his name, local journalists reported.
"This victory represents the interest of the Somali people," Farmaajo said after taking the oath of office. "This victory belongs to the Somali people, and this is the beginning of the era of the unity, the democracy of Somalia and the beginning of the fight against corruption."
Farmaajo was born in Mogadishu and once worked in the foreign ministry, which deployed him to Somalia's embassy in Washington in 1985.
He left the embassy in 1989 to study at the State University of New York in Buffalo. After the collapse of the Siad Barre regime in 1991, when Somalia erupted in clan warfare, Farmaajo sought asylum in the U.S.
He eventually became a U.S. citizen, served as equal employment commissioner for the New York state Transportation Department and wrote a master's thesis titled: "U.S. Strategic Interest in Somalia: From the Cold War Era to the War on Terror."
In 2010, he returned to Mogadishu to take up the post of prime minister, a job to which he was appointed.
As prime minister, Farmaajo was seen as a reformer who made sure that security forces got paid, forced lawmakers to disclose their assets and set up an anti-corruption commission.
The vote Wednesday was tinged by corruption. The electors were lawmakers who themselves were chosen in October by 14,000 clan leaders, politicians, elders and community figures in an election marred by vote buying, bribes, threats and at least a few killings.
A local anti-corruption group, Marqaati, reported that more than a quarter of the voters in the October election that it interviewed had been harassed or intimidated and that 32% of elders had been offered bribes.
Votes were sold for as much as $30,000 each and candidates paid more than $300,000 in bribes to get parliamentary seats, the group said.
Several candidates pulled out of the presidential race in protest.
Somalia aims to hold direct elections in 2020, giving ordinary Somalis a chance to vote. Officials have said that doing so currently is too risky, given insecurity and clan tensions.
Farmaajo defeated 20 other presidential candidates. In the first round of voting, no candidate received the two-thirds majority needed to win the election. The top four candidates advanced to the second round, where 165 votes were required to win and avoid a third round. Farmaajo received 184.
The incumbent president, Hassan Sheikh Mohamud, was second with 97 votes. A former peace activist, he had faced criticism for being too close to the Ethiopian government, which had sent forces into Somalia to fight Shabab but withdrew them late last year.
Fayumo Dayib, a candidate who withdrew from the race saying the process was corrupt, tweeted her joy when Mohamud was defeated and Farmaajo emerged as the victor.
"History in the making. Lawmakers have clearly chosen the choice of the people. They've saved #Somalia!! It is a new dawn, a new beginning!"
The election is a modest step toward political stability. But Somalia remains fragile because of looming famine and Shabab, which has carried out a series of devastating attacks in recent months.
Security forces and civil servants have gone unpaid for months, and the United Nations recently warned that some members of the Somali army could defect to Shabab.