Many are hoping that the vote -- which concluded peacefully but was dogged by claims of irregularities -- will draw a line under a political crisis that has lasted well over a year.
Outgoing president Mohamed Abdullahi Mohamed's term ended in February 2021 without an election and the protracted tussle for power that followed turned violent at times and caused divisions at the highest levels of government.
Somalia's international partners had repeatedly warned that the election delays were a dangerous distraction from the fight against Al-Shabaab insurgents, who have been trying to overthrow the government for more than a decade.
On Monday, the UK's minister for Africa congratulated Mohamud, who ruled Somalia between 2012 and 2017 and is the first president to win a second term in the troubled Horn of Africa nation.
The UK "looks forward to continuing its close work to support on building stability, tackling Al-Shabaab and supporting those affected by the devastating drought", minister Vicky Ford said on Twitter.
Mohamud has promised to transform Somalia into "a peaceful country that is at peace with the world".
The East African regional bloc IGAD said Mohamud's victory was "a clear testimony of the trust and confidence that the people of Somalia have in his leadership qualities".
Somalia has not held a one-person, one-vote election in 50 years and few of its 15 million people played any part in choosing Mohamud.
Instead, polls follow a complex indirect model, where state legislatures and clan delegates pick lawmakers for the national parliament, which in turn chooses the president.
- 'Heal grievances' -
But some in the capital welcomed the appointment of Mohamud, a former academic and peace activist, whose first administration was dogged by claims of corruption and infighting.
"I can't express in words how happy I am, Allah willing. I am very, very happy," Mogadishu resident Hassan Mohamud Mohamed told AFP.
In addition to tackling a looming famine caused by drought, Mohamud will also need to repair the damage done by months of political infighting, both at the executive level and between the central government and state authorities.
At his swearing-in after midnight on Sunday, he hailed his predecessor for enabling a peaceful transfer of power. "We must move forward and never backwards. We have to heal any grievances," he said.
In a reminder of the country's treacherous security situation, explosions were heard on Sunday near Mogadishu's heavily-guarded airport complex, where lawmakers were voting. Police said no casualties were reported.