A crisis in the Gulf has had an unexpected consequence - a rush to build ports all down the Somali coast. But, as Mary Harper writes, some fear it could tear the Horn of Africa apart.
Somaliland's port town of Berbera is sleepy and somewhat scruffy. Paintings of fish, crabs and sailboats adorn the faded buildings. Tangled nets lie in the sandy streets.
It is hard to imagine that this charming seaside town is at the centre of an almighty row between Somalia and this self-declared republic which broke away in 1991 but has not been recognised internationally.
This dispute is part of a far wider problem. A crisis in the Gulf is playing out in dramatic form in Somalia and the wider Horn of Africa. Some argue it could tear the whole region apart.
After nearly 30 years of conflict and instability, Somalia is particularly vulnerable.
"Somalia has become a chessboard in the power game between Qatar and Turkey on the one side and Saudi Arabia, the United Arab Emirates and their allies on the other," says Rashid Abdi, director of the Horn of Africa project at the International Crisis Group.
"There is no doubt that these rivalries are spilling over into Africa. Somalia is especially vulnerable because of its proximity to the Gulf and its long historical relationship with the region."
The disagreement between Somalia and Somaliland centres around two deals, both connected with the UAE.
The UAE is building a massive military base in Berbera. It is a highly strategic location. The US and the former Soviet Union built bases there decades ago, plus one of the continent's longest runways, which is more than 4km (2.5 miles) long.
For the Emirates, Berbera is conveniently close to Yemen where it is part of the Saudi-led coalition fighting Iranian-backed Houthi rebels. The UAE has another military facility up the coast in Eritrea's port town of Assab.
Meanwhile the Dubai-based company DP World is taking over the port, which exports millions of live animals to the Gulf every year. Landlocked Ethiopia is also involved, with a 19% stake, as it sees Berbera as a useful alternative to the congested, expensive port in Djibouti upon which it is totally dependent.
Although Somaliland is not recognised as an independent country, it operates as if it is. It is more stable than the rest of Somalia, has a functioning economy, and its own government, legal system, currency and flag. Power has been transferred peacefully during a series of elections since it declared independence 26 years ago.
But Somalia regards Somaliland as part of its territory. Earlier this month parliament in Somalia voted to nullify the port deal.
"Somaliland and DP World have been very arrogant and disrespectful," says Somali Foreign Minister Ahmed Isse Awad. "The company cannot legally sign an agreement without our consent. We will not allow any party to violate our sovereignty and territorial integrity."
But DP World and Somaliland remain committed to the project. They probably know that, in practice, the authority of the Somali federal government does not extend far beyond the capital Mogadishu.
There has been no strong central authority since the fall of President Siad Barre in 1991. An Islamist insurgency began more than a decade ago, and much of Somalia is controlled by al-Shabab militants and other armed groups.
Somaliland's ambassador to the UAE, Bashe Awil Omar, describes Somalia's hostility to the deal as "ludicrous".
"We have been managing our own affairs for nearly 30 years. Somalia has not contributed anything to our territory so why is it interfering now?"
Mr Omar says the military base will be a good thing for Somaliland. "It will protect our coastline. UAE troops will train our security forces. They will also use the base to launch attacks on Yemen."
But it is easy to understand why Somalia is concerned. Not only has a breakaway republic signed significant economic and military agreements with a foreign power, but the UAE is also bypassing the federal government by striking deals with Somalia's regional states.
These five states have a fractious relationship with central government and with each other. Some have received military training, equipment and funding from the Emirates. DP World and its subsidiaries are negotiating deals to manage a string of ports in at least three of them.
The situation is different in the capital Mogadishu.
As you fly in low over the turquoise sea to the airport, stretched along the beachfront is a vast Turkish base. It is said to be its largest military training facility outside Turkey. Mogadishu's lucrative port, which used to be fought over by warlords, is now run by a Turkish company, Al Bayrak.
The Somali federal government has been put in a difficult position. It owes allegiance to Qatar and Turkey, but its key trading partners, Saudi Arabia and the UAE, are on the other side of the Gulf divide.
Saudi Arabia imports 80% of Somalia's livestock, compared with the meagre 3.5% imported by Qatar. In a port in Dubai, fridges, building materials and air conditioners are loaded onto dhows bound for Somalia, manned by Gujarati crews.
Somalia insists it holds a neutral position in the Gulf crisis. But its regional states have played havoc with its diplomacy by declaring allegiance to the Saudis and the UAE.
The Horn of Africa expert Alex de Waal argues that the crisis in the Gulf has an impact way beyond Somalia.
"This has the potential to deepen the fractures across the whole region. The Arab states, including Egypt, are trampling across the painstakingly built norms and institutions for Africa's peacemaking with their cynical, unilateral divide-and-rule realpolitik."