Tensions between Somalia and the United Arab Emirates ratcheted up this week as Mogadishu ditched a military deal with its ally and seized millions of dollars in cash from an Emirati plane.
The escalation came after months of building friction in Somalia as the Gulf crisis pitting Arab powers against each other spills over into the fragile state, whose position of neutrality has not gone down well at home or with its allies.
Rashid Abdi, an analyst with the International Crisis Group, told AFP that while the UAE and Somalia have traditionally been close, and Mogadishu has vowed to remain neutral over the Gulf divisions, the central government is nevertheless "perceived to be very much pro-Qatar".
Some of Somalia's federal states were unhappy with President Mohamed Abdullahi Mohamed's neutral stance, and have broken with the official position to side with the UAE.
Diplomatic tensions first spilled into the open in March after the Dubai-based DP World gave Ethiopia a 19 per cent stake in the Berbera port in breakaway Somaliland — whose independence is not recognised by Mogadishu.
Lawmakers in Somalia, which also has a history of animosity with Ethiopia, adopted a resolution accusing the company of having "intentionally violated the sovereignty of Somalia".
Tempers have also flared over a military base being built by the UAE in Somaliland.
On Sunday, Somali security forces stormed onto a UAE civilian aircraft at the international airport, and seized $9.6 million in cash held in three unmarked bags.
"The security forces noticed the suspicious bags and handed them over to the concerned departments," Somalia's security ministry said in a statement.
However the UAE in a statement accused security forces of holding those on the plane "at gunpoint", and said the cash had been allocated to support the Somali army and trainees.
"The current Somali government ... is creating unnecessary tensions with a friend and an ally who supported the stability and security of Somalia during its hardest phases," tweeted UAE state minister for foreign affairs Anwar Gargash.
"We call for wisdom and reason".
Just days later, on Wednesday, Somalia's defence ministry announced it was taking over the management of hundreds of Somali troops who had been trained by the UAE.
The UAE has been running a military camp in Mogadishu where it trains Somali soldiers, who are also paid by Emirati officials.
"As a government, our responsibility is to take care of our armed forces and pay their wages and not to delegate that responsibility to others. We thank the UAE for the training and relentless support it provided," Defence Minister Mohamed Mursal told a local news agency.
Experts describe the bloated and largely ineffective Somali army as more a collection of clan militias, with various international militaries providing poorly-coordinated training to different units.
The security of the country, battling the Al-Qaeda-linked Shabaab extremists, has largely been propped up by Amisom, the African Union peacekeeping force, which is due to withdraw by 2020.
'Vulnerable and weak'
The 10-month Gulf crisis pits Saudi Arabia, the UAE, Egypt and Bahrain against Qatar — which has been accused by its rivals of fostering close links with Tehran and supporting Islamist extremists. Qatar denies the charges.
With close geographic, political, economic and cultural ties with the Gulf, observers warn the Horn of Africa is facing heightened instability as countries come under pressure to pick sides while Arab powers jockey for political influence.
Somalia has not had an effective central government since the 1991 overthrow of president Siad Barre's military regime which ushered in decades of anarchy and conflict.
Abdi warned the Gulf crisis could have a "serious destabilising impact on Somalia."
"There's no doubt that the Gulf crisis has spilled over into the Horn. Now countries which are strong can manage this war, but Somalia is very vulnerable and very weak," he said.