The 55-year-old father of four, better known as Farmajo, holds both American and Somali citizenship, and was elected after a six-month voting process marred by widespread allegations of vote-buying and corruption.
Nevertheless, Farmajo, from the Darod clan, was welcomed with celebration by many Somalis who had looked forward to change after a series of Hawiye presidents.
In a country where clan divisions dominate politics, the administration of his predecessor, Hassan Sheikh Mohamud, was widely seen as more corrupt than any that came before him.
As president, Farmajo inherits a country where al-Shabaab extremists hold swathes of countryside and attack Mogadishu at will.
And after decades of unrest, hundreds of thousands of Somalis have been displaced internally, or else have fled the country.
“This is the beginning of unity for the Somali nation, the beginning of the fight against Shabaab and corruption,” a triumphant Farmajo said after being declared president.
Many Somalis fondly remember the eight months when Farmajo – whose nickname means “cheese” – was prime minister in 2010-11.
On his Facebook page, Farmajo says that while premier, he implemented the first monthly stipends for soldiers, worked on the country’s new constitution and sent delegations to defuse clan-related tensions in several regions.
The soldiers firing celebratory gunfire in the streets of Mogadishu on Wednesday have not been paid for months.
And in a report this week, the Somali anti-corruption NGO Marqaati said civil servants had gone unpaid so the government could pay for lobbying during the elections.
In his time as prime minister, Farmajo also established an anti-corruption commission, prohibited unnecessary trips abroad by members of government and put in place an audit of government property and vehicles.
In 2011, after months of political infighting over the holding of presidential elections, a deal was struck to postpone the vote in exchange for Farmajo’s resignation.
He agreed to step down in “the interest of the Somali people and the current situation in Somalia”.
In early 2012 Farmajo and members of his former cabinet set up the Tayo (“Quality”) political party.
On his Facebook page, he says that the party’s priority was “encouraging the repatriation of Somali diasporans so as to assist in the post-conflict reconstruction process.”
Farmajo was born in Mogadishu to activist parents from the southern Gedo region.
He has lived off and on for years in the United States, where he studied history and political science.
He worked at the foreign ministry before the overthrow of Siad Barre’s regime in 1991 ushered in decades of anarchy. He also worked at the Somali embassy in Washington.
Before being appointed prime minister he spent several years working in New York for the Buffalo Municipal Housing Authority and the Erie County Division of Equal Employment Opportunity, as well as the New York State Department of Transportation.