The joy was palpable on the streets of Mogadishu as one of the most unlikely candidates, Mohamed Abdullahi Farmajo (pictured), was declared the winner of the presidential election in Somalia last week.
There was double jubilation in Nairobi's Eastleigh area and the Dadaab refugee camp, where Somali refugees celebrated both a new president and a High Court ruling that declared the Kenya Government's decision to close down the camp and repatriate all Somali refugees to Somalia as "null and void".
It was a surprise election victory. In a country deeply divided along clan lines, it was expected that the incumbent, Hassan Sheikh Mohamud, who is reported to have had the support of countries such as the United Arab Emirates, Turkey and Ethiopia, would win.
Mr Farmajo's victory was also unexpected because it was rumoured that many of the candidates had heavily bribed MPs to vote for them, with some estimates indicating that millions of dollars had changed hands. In the end, as one commentator put it, people took the money but still voted for their choice.
Mr Farmajo served as prime minister in former President Sharif Sheikh Ahmed's government, but his tenure was short-lived.
During his time as prime minister, he tried to bring a semblance of order to Somalia's chaotic government by establishing an anti-corruption commission and instilling some kind of discipline in the civil service, a Herculean task, as most of Somalia was, and remains, a largely clan-based informal war economy where armed groups control both territory and economic assets.
Mr Farmajo, who is a dual citizen of the United States and Somalia, also tried to make revenue collection and government expenditure more transparent, but this proved to be extremely difficult as there were no functioning financial or regulatory institutions to speak of.
One report indicated that millions of dollars of domestic revenue from Mogadishu port and donor money from Arab countries simply vanished once the money arrived at Somalia's dysfunctional Central Bank.
Senior government officials in Somalia are notorious for siphoning money intended for the people of Somalia -- yet another reason the country has remained a failed state for so long.
This time around, hopes are high that the new president could achieve what his predecessors failed to do. Unfortunately, he assumes the presidency at a time when Somalia is facing several challenges.
A looming famine threatens the lives of millions. Al-Shabaab is still unleashing havoc in Mogadishu and many parts of southern and central Somalia.
The Somali Army is weak and underfunded; the government has been relying on Amisom forces for security for almost a decade.
To end the mayhem, Mr Farmajo may need to negotiate a settlement with Al-Shabaab and other radical elements. Lessons can be drawn from Somaliland and Puntland, which have successfully managed to ward off the terrorist group.
A nationwide reconciliation is also needed to bring in minority clans and women, who have remained largely marginalised.
Mr Farmajo reportedly does not support the so-called 4.5 federal system that gives undue advantage to the four largest clans and which has broken Somalia into clan-based fiefdoms -- otherwise known as federal states.
Currently these states operate largely without any reference to Mogadishu. Bringing them into the national fold should be one of his major tasks.
He will also need to reconfigure Somalia's relationship with its neighbours, Ethiopia and Kenya, so that the relationship is mutually beneficial and not antagonistic and interventionist as it has been for decades.
The withdrawal of Ethiopian and Kenyan troops from Somalia would help this process.
Most importantly, the new president will need to eliminate corruption and restore Somalia's institutions, including its ministries, the judiciary, the central bank and revenue-collecting institutions.
Without a healthy domestic revenue base and accountable government institutions, Somalia cannot emerge from the ashes.
Unlike his predecessors, Mr Farmajo is viewed as someone who has a nationalistic mindset and one who is not prone to be influenced by clan interests or Islamist radicals.
These are the qualities that got him elected. With so much goodwill, the new Somali president cannot afford to fail his people.
As one Somali told me, Somalis were fed up with the clannishness and corruption of the previous government, and so are ready for a change. Let us hope that Mr Farmajo will not disappoint them.
Rasna Warah is an analyst and commentator based in Nairobi.