Incumbent President Hassan Sheikh Mohamud conceded defeat after two rounds of voting Wednesday, and former prime minister Mohamed Abdullahi Farmajo became the new president and quickly took the oath of office.
Former Somali prime minister Mohamed Abdullahi Farmajo was sworn in as the president of the country late Wednesday. Celebratory gunfire was heard across the city at his victory.
The indirect elections took place in Mogadishu's secure airport compound after months of delays and threats from Islamist insurgents bent on derailing the process. The protracted vote began with 14,000 elders and prominent regional figures choosing 275 members of parliament and 54 senators, who in turn chose whether to back President Hassan Sheikh Mohamud for a second term or one of 21 rivals.
However, the lawmakers gave Farmajo an unassailable lead in the second round of an election. Mohamud conceded defeat as it became clear he would be unable to win a third round of voting.
"This is a victory for Somalia and the Somalis," Farmajo told the members of parliament and senators who had gathered in a hall behind the airport's blast walls to vote. He had been sworn in moments earlier.
Farmajo, who holds degrees from the State University of New York in Buffalo, was prime minister for eight months before leaving the post in 2011. He had lived in the United States since 1985 when he was sent there with Somalia's foreign affairs ministry.
Somalia is one of seven countries whose citizens have been temporarily banned from entering the US under the Trump administration. Farmajo, however, has a US passport.
Somalia was on US President Donald Trump's list even though the country has become an increasingly important partner for the US military in counter-terrorism efforts, including drone strikes against al-Shabab leaders.
Somalia began to fall apart in 1991 when warlords ousted dictator Siad Barre and then turned on each other. Years of conflict, al-Shabab attacks and famine left this Horn of Africa country of about 12 million people largely shattered.
TRT World's Fidelis Mbah brings more information on Somalia.