It isn’t often that Somalia gets to be the site of international optimism.

The country hasn’t had a fully functioning national government in nearly three decades. It is still struggling to wrench back large swaths of its territory from terrorists and pirates. And just last week the United Nations warned that famine is imminent if international donors don’t quickly intervene.

All things told, Somalia seems from afar like a country conjured up by failed state central casting – anarchic and unsalvageable.

But reality has a way of cutting oversized stereotypes like that down to size. And that was exactly what happened Wednesday night in Mogadishu, as Somalis celebrated a small but important success in their halting fight for normalcy. They elected a new president. And if the scenes on the streets of Mogadishu and in Somali communities around the world were anything to go by, people seem to actually like him.

That the election would be won by a candidate popular among ordinary Somalis might seem a strange thing to celebrate, but it was never a given, considering they didn’t actually get to cast a vote. Instead, their president was chosen by members of parliament, who were themselves elected by delegates who had been appointed by the country’s 135 clan elders. (Got all that? Here’s a flow chart.) The vote, initially scheduled for last year, was marred by delays and widespread bribery, with Somalia’s Auditor General Nur Jimale Farah estimating that a single MP’s presidential vote cost as much as $1.3 million. (The country hopes to hold direct elections in 2020.)

And the idea that the election could be won by someone who wasn’t the current president was, until last night, never clear, either. For much of 2016, Somalia’s civil servants, police, and Army did not receive a single paycheck, as money from state coffers was siphoned into the dirty election campaign – much of it aimed at the president’s reelection – according a new report by Somali anticorruption watchdog Marqaati.

“Though the process was really bad, the outcome was good,” says Abdirashid Hashi, a former Somali cabinet minister and political analyst. The new president, Mohamed Abdullahi Mohamed, who goes by the nickname “Farmajo” (a play on the Italian word for cheese) briefly served as Somalia’s prime minister in 2010-11, and has a reputation from his former tenure for shrinking government bloat, modernizing the bureaucracy, and speaking out against corruption. (A dual US citizen, he also has a reputation for being a diligent employee of the New York Department of Transportation for many years.)

“But of course Somalia’s challenges are much larger than an individual,” says Mr. Hashi, who worked in Mr. Mohamed’s first cabinet.

That is indisputable.

When he comes into office, Mohamed will inherit a government that still doesn’t control large pieces of its supposed territory in southern Somalia. Terror attacks are a regular occurrence – there were at least two the same week as the election – and the country is still ranked the most corrupt on earth by international watchdog Transparency International.

“This is a good step towards stability, but it’s a small step,” says Omar Mahmood, a researcher with the Institute for Security Studies in Addis Ababa, Ethiopia. “Farmajo will absolutely have his work cut out for him.”

Many of the same superlatives placed on Mohamed’s shoulders, he notes, were once placed on his predecessor, Hassan Sheikh Mohamud, who was cast ahead of the 2012 elections as a vote against corruption and insecurity. “We’ve seen a lot of this before,” Mr. Mahmood says. “In Somali politics there are no promises.”

There are no promises either for how Mohamed’s election could affect Somalia’s complicated relationship with the United States – for whom the country appears at times to be both a valuable counterterrorism ally and a fertile breeding ground for America’s enemies. This year, the US plans to give Somalia approximately $132 million in “peace and security” aid. Meanwhile, a now contested executive order by President Trump last month barred all Somali passport holders from entering the US for 90 days as part of a program to better control immigration from corners of the globe perceived to be staging areas for anti-American terrorism.

Mohamed’s existing ties to the US could be an asset, says Hashi, the former minister, and his history of voting for the Republican Party could endear him to the Trump administration in particular.

Get the Monitor Stories you care about delivered to your inbox. By signing up, you agree to our Privacy Policy

But a more stable and popular national government in Somalia, regardless of who is at the helm, is also likely to be helpful to the US in other ways, too, says Mohamed Mubarak, the founder of Marqaati, the anti-corruption NGO. For one thing, it could help US aid money more easily reach its recipients, be they communities facing famine or security forces fighting the Al Shabab terrorist group.

“If Somalia fails, it’s not good for Somalia, of course, but it’s also not good for the United States,” he says. “They owe it not just to Somalia but to their own taxpayers as well to make sure that doesn’t happen.”