Somalia's new president Hassan Sheikh Mohamud, who was elected after a marathon vote by lawmakers on Sunday, is a former academic and peace activist whose first administration was dogged by claims of corruption and infighting.
Born in 1955, Mohamud was a fierce critic of the incumbent Mohamed Abdullahi Mohamed, better known as Farmaajo, since the latter won the 2017 presidential vote, beating the ex-university professor's bid for re-election.
When Farmaajo sought to extend his rule by decree after his term ended without a fresh vote, Mohamud played a key role in the violent protests that rocked the capital Mogadishu and forced the president to seek consensus on the way forward.
The first Somali president to win a second term, Mohamud has promised to transform Somalia into "a peaceful country that is at peace with the world".
He will inherit several challenges from his predecessor, including a devastating drought and a long-running fight with Al-Shabaab insurgents, who tried to assassinate him during his first term.
He 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.
A member of the powerful Hawiye clan, Mohamud entered politics in 2011 when he founded the Union for Peace and Development Party.
Few expected the bookish activist to become president and his 2012 election victory raised hopes that the fragile Horn of Africa 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 his term was marked by corruption scandals and political turmoil.
Two of the three prime ministers he appointed were forced out because of disagreements with him, while two central bank governors quit their jobs as graft allegations swirled around his administration, claims he dismissed.
By the time his term came to an end, his administration was widely seen as more corrupt than any other that had come before, prone to wrangling over jobs, cash and power.
Born in Jalalaqsi in the central Hiran region, Mohamud studied at Somalia's national university before the civil war broke out in 1991.
He had acquired his primary education in his home town before continuing secondary education in the capital Mogadishu.
He attended and received his first higher education qualification from the National Polytechnic College, an affiliate of the Somali National University in 1981, earning Bachelor of Technology.
In 1986 he proceeded to India where he studied at Barkatullah University (ex-Bhopal University) until 1988, earning a Master of Technical Education.
During his presidency, Mohamoud visited India in 2015 when Barkatullah University awarded him an honorary doctor of literature.
Before politics, he spent most of his working life in the education sector in Somalia, teaching at colleges and universities.
When the central government of Somalia collapsed, following challenges by armed rebel groups, Mohamoud joined other intellectuals in an effort to revive the education of the young generation that were overwhelmed by war in the 1990s.
He became the first Chancellor of Somali Institute for Management and Development (Simad) College which later became one of the biggest higher education institutions in the Somali capital and was later renamed Simad University.
As a researcher and academic, Mohamoud published a number of papers, including The Role of Somali Civil Society Organisations (CSOs) in Conflict and Peace; The Somali Diaspora and its Role in Development; and A History of Mediation in Somalia Since 1988.
In 2001, Mohamoud joined the Centre for Research and Dialogue (CRD) that gave him an opportunity to travel across the country, preaching peace and inculcating reconciliation.
He served stints with the UN children's agency Unicef before co-founding Simad in 1999.
Following his success in marshalling the support of other anti-Farmaajo presidential candidates, he will now need to focus on reuniting the country, observers say.
"The country is very polarised at the moment," Samira Gaid, executive director of the Mogadishu-based Hiraal Institute think-tank, said ahead of Sunday's poll.
"This electoral process that has been so protracted offers a reset button.