MOGADISHU, Somalia (AP) -- A former prime minister who holds dual Somali-U.S. citizenship was elected Somalia's president on Wednesday, declaring a new "era of unity" as he took on the daunting task of bringing the long-chaotic country its first fully functioning central government in a quarter-century.
Fears of attacks by the Islamic extremist al-Shabab dogged the historic vote, which was limited to lawmakers instead of the population at large, with members of the upper and lower houses of parliament casting ballots at a heavily guarded former air force base in the capital, Mogadishu, while a security lockdown closed the international airport.
"This victory belongs to the Somali people," the newly elected president, Mohamed Abdullahi Farmajo, declared after taking the oath of office. "This is the beginning of the era of unity, the democracy of Somalia and the beginning of the fight against corruption."
"There is a daunting task ahead of me, and I know that," he said.
Thousands of jubilant Somalis poured into the streets, chanting the new president's name as cheering soldiers fired into the air. "Somalia will be another Somalia soon," said Ahmed Ali, a police officer celebrating in the crowd.
Incumbent President Hassan Sheikh Mohamud conceded defeat after two rounds of voting, saying: "History was made. We have taken this path to democracy."
Mohamud held a slight lead over Farmajo after an initial round of voting Wednesday that included a field of 21 candidates. But Farmajo easily won the second round contested among three candidates, with 184 votes to Mohamud's 97.
The new president represents a generation of Somalis scattered abroad by conflict who cautiously have begun to return to help their homeland recover. Most of the candidates in the election held dual citizenship.
Farmajo, who is in his mid-50s and holds degrees from the State University of New York in Buffalo, was prime minister for eight months before leaving the post in 2011. While he was in office, al-Shabab was expelled from Mogadishu, his campaign biography says. He had lived in the United States since 1985, when he was sent there with Somalia's foreign affairs ministry.
Somalia began to fall apart in 1991, when warlords ousted dictator Siad Barre and then turned on each other. Years of conflict and al-Shabab attacks, along with famine, left this Horn of Africa country of some 12 million people shattered.
Across Mogadishu, Somalis had gathered around TV screens at cafes and homes, eagerly watching the vote. "We need an honest leader who can help us move forward," said Ahmed Hassan, a 26-year-old university student.
Somalia's instability landed it among the seven Muslim-majority countries affected by President Donald Trump's executive order on immigration, even though its government has been an increasingly important partner for the U.S. military on counterterrorism efforts, including drone strikes against al-Shabab leaders.
As an American citizen, Farmajo will be able to travel to the United States despite the ban.
In a sign of the dangers that remain in Mogadishu, two mortar rounds fired by suspected extremists late Tuesday hit near the election venue. There were no such attacks reported in the capital on Wednesday and no public statements by al-Shabab.
The international community pushed Somalia to hold the election as a symbol of strength, with the U.S. pouring in hundreds of millions of dollars in recent years for political and economic recovery. But the election was marred by reports of widespread graft in a country recently ranked as the world's most corrupt by Transparency International.
The legislators voting — 275 members of the lower legislative house and 54 senators — were selected by the country's powerful, intricate network of clans. Weeks ago, a joint statement by the United Nations, the U.S., the European Union and others warned of "egregious cases of abuse of the electoral process."
With reports of votes being sold for up to $30,000 apiece, "this is probably the most expensive election, per vote, in history," the Mogadishu-based anti-corruption group Marqaati said in a report released Tuesday.
"We encourage Somalia's new administration to take credible steps to stamp out corruption and to establish strong electoral institutions to enable a free and fair one-person, one-vote poll in 2020," State Department spokesman Mark Toner said as the U.S. congratulated Farmajo.
Britain's foreign secretary, Boris Johnson, said the U.K., which is hosting an international donors conference on Somalia in London later this year, was ready to help address the "significant challenges" facing the country as it recovers from two decades of civil war, including reducing the risk of famine, improving security and undertaking constitutional and electoral reforms.
"This is a crucial opportunity to accelerate progress and agree priorities that will help secure a brighter future for Somalia and its people," Johnson said.
Tremendous challenges remain for Somalia and its new president, even beyond graft, al-Shabab attacks and an economy propped up in part by the country's diaspora of more than 2 million people.
An African Union peacekeeping force of more than 20,000 is making plans to pull out of the country by the end of 2020, leaving the job to national security forces that observers have said remain underprepared.
Meanwhile, hundreds of thousands of Somali refugees are under pressure to return home as neighboring Kenya's government seeks to close the world's largest refugee camp, Dadaab, by the end of May. Human rights groups have warned that Somalia is hardly equipped to support the returnees — especially as the United Nations and others warn that drought is creating a humanitarian crisis for almost 3 million Somalis.