Sworn in early on Monday, Hassan Sheikh Mohamud becomes the first Somali president to win a second term. He has vowed to transform the troubled Horn of Africa nation into "a peaceful country that is at peace with the world."
Somalia's new president is a former academic and peace activist whose first administration was dogged by claims of corruption and infighting.
Sworn in after midnight on Sunday following a marathon vote by lawmakers, Mohamud will inherit several challenges from his predecessor Mohamed Abdullahi Mohamed.
These include the results of a devastating drought and the long-running fight with Al-Shabaab insurgents who tried to assassinate Mohamud during his first term between 2012 and 2017.
Hassan Sheikh Mohamud will also need to repair the damage caused by months of political chaos and infighting, both at the executive level and between the central government and state authorities.
Call for peace and reconciliation
At his swearing-in in the capital Mogadishu, Mohamud struck a conciliatory tone, praising his predecessor for enabling a peaceful transfer of power.
"It is indeed commendable that the president is here standing by my side. We must move forward and never backwards, we have to heal any grievances," he said.
The pair's bitter rivalry dates back to 2017, when Mohamud lost his bid for re-election to Farmajo, as Mohamed Abdullahi Mohamed is known.
In February 2021, violent protests broke out when Farmajo sought to extend his rule by decree after his term ended without a fresh vote. Mohamud was a key figure in forcing the president to seek consensus.
Following his success in marshalling the support of other anti-Farmajo presidential candidates, Mohamud will now need to focus on reuniting the country, observers say.
Five years of polarisation
"The past five years have been very polarising," Samira Gaid, executive director of the Mogadishu-based Hiraal Institute think tank, told the French AFP press agency.
"His message to the federal member states and the MPs who supported President Farmajo, is not to fear his presidency."
Reconciliation and political dialogue are seen as the crucial requirements of the new regime.
Somalia's international partners on Monday welcomed the news of his election.
African Union Commission chief Moussa Faki Mahamat sent his congratulations, as did the leaders of Somalia's immediate neighbours Ethiopia, Kenya and Djibouti.
The East African regional bloc IGAD said his victory was "a clear testimony of the trust and confidence that the people of Somalia have in his leadership qualities".
First term marred by corruption
Mohamud entered politics in 2011 when he founded the Union for Peace and Development Party.
His surprise 2012 election victory raised hopes that the fragile nation was on the path to stability.
His government was the first to be given global recognition and billions in foreign aid since the collapse of Siad Barre's authoritarian regime in 1991.
But the technocrat's first term was marked by corruption scandals and political turmoil.
Two of the three prime ministers Mohamud appointed were forced out because of disagreements with him, while two central bank governors quit their jobs as graft allegations swirled around his administration.
By the time his term came to an end, his administration was widely regarded as the most corrupt ever seen in Somalia .
Background in conflict resolution
Born in 1955 in Jalalaqsi in the central Hiran region, Mohamud studied at Somalia's national university before civil war broke out in 1991, and then at Bhopal University in India. He is a member of the powerful Hawiye clan
He worked with the UN children's agency UNICEF before co-founding the Somali Institute of Management and Administrative Development in 1999.
Prior to entering politics, he spent two decades working in education and in conflict resolution -- the latter is likely to prove a useful skill in his second term.