Somalia handed Hassan Sheikh Mohamud the presidency for a second time following Sunday’s long-overdue election in the troubled Horn of Africa nation, which is confronting an Islamist insurgency and the threat of famine.

After a marathon poll involving 36 candidates that was broadcast live on state TV, parliamentary officials counted 214 votes in favour of former president Mohamud, far more than the number required to defeat the incumbent Mohamed Abdullahi Mohamed, better known as Farmajo.

Celebratory gunfire erupted in the capital Mogadishu, with many hoping that the vote will draw a line under a political crisis that has lasted well over a year, after Farmajo’s term ended in February 2021 without an election.

Mohamud, who was previously president from 2012-2017, was sworn in shortly after the vote were counted and struck a conciliatory tone as he addressed the country.

“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, referring to Farmajo, who hailed the successful completion of the long-awaited poll.

“I welcome my brother here, the new president Hassan Sheik Mohamud and wish him luck with the huge task... we will be in solidarity with him,” Farmajo said.

Somalia’s international partners had repeatedly warned that the election delays – caused by political infighting – were a dangerous distraction from the fight against Al-Shabaab insurgents who have been fighting to overthrow the government for more than a decade.

In a reminder of the country’s treacherous security situation, explosions were heard Sunday near Mogadishu’s heavily-guarded airport complex where MPs were voting. Police said no casualties were reported in the blasts.