IT SEEMED an irrational decision 20 years ago. DP World is one of the world’s largest maritime firms. From a squat office overlooking Dubai’s bustling Jebel Ali port, it directs operations in 40 countries. Most are in busy shipping hubs such as London and Rotterdam. But in the 1990s it started making surprisingly big investments in the Horn of Africa. It built a large port in Djibouti, and is now working on another in Somaliland (see map). The combined GDP of the two African entities is smaller than that of Moldova. Yet the firm sees the region as a land of opportunity.

So do the rulers of United Arab Emirates (UAE), one of whose components, Dubai, owns a majority stake in DP World. It is one of several Gulf states trying to gain a strategic foothold in east Africa through ports. Controlling these offers commercial and military advantages but risks exacerbating tensions in the region.

Executives at DP World argue that Africa needs many more ports—especially in the Horn, where conflict has stifled trade. Ethiopia, populous and fast-growing, lost its coastline when Eritrea broke away in 1991. Its 105m people rely on Djibouti for 95% of their trade. Farther inland, countries such as South Sudan, Uganda and Rwanda struggle to reach markets. DP World thinks the region from Sudan to Somalia needs 10-12 ports. It has just half that. “The whole Horn of Africa is short of ports. It’s stifling,” says one executive.

The firm’s first foray was on Djibouti’s coast. When DP World won its first concessions there in the 1990s, the Emiratis were among the few investors interested in the small and poor former French colony. DP World built and operated a new container terminal, Doraleh, and helped finance roads and other infrastructure. Doraleh is now the country’s largest employer and the government’s biggest source of revenue. It runs at nearly full capacity, handling 800,000 containers a year. Much of its cargo travels along a Chinese-built railway from Addis Ababa, Ethiopia’s capital.

Djibouti’s profile rose further after the terrorist attacks on America of September 11th, 2001, when America opened a military base there. France and China also have bases; other navies patrol off its coast to deter Somali pirates. But when the Emiratis wanted to open their own naval base they were rebuffed, partly because of their close ties to Djibouti’s rival, Eritrea (the two states had a bloody border dispute in 2008). In 2015 the UAE started building a naval base in Assab, in southern Eritrea. The base has been used in the Saudi-led war against Houthi rebels in Yemen. It would be the jumping-off point for a mooted amphibious assault on Hodeida, Yemen’s main port, now the focus of heavy fighting. The UAE also helped mediate Eritrea’s peace deal with Ethiopia signed on July 9th, ending decades of hot and cold war. If it holds, the truce could end UN sanctions and open Eritrea to investment. Assab and another port, Massawa, could be expanded.

In 2016 DP World won a 30-year concession to operate the port of Berbera in Somaliland, which declared independence in 1991 (though no foreign government recognises it). Critics said the deal would hasten the break-up of Somalia. Djibouti was upset for different reasons. With a planned capacity of 1.25m containers, Berbera would erode Djibouti’s monopoly on Ethiopian cargo. Indeed, Ethiopia acquired a 19% stake in the port earlier this year. All this could cost Djibouti hundreds of millions in annual transit fees.

It would also cement the UAE’s place in a strategic region. Uniquely among Arab states, it tries to project military power far beyond its borders. The Horn ports all sit near the Bab al-Mandab strait, a vital choke-point at the mouth of the Red Sea: 4.8m barrels of oil passed through it every day in 2016. Competition is getting fierce, though. Qatar and its ally, Turkey, are building ports in Sudan. Saudi Arabia is in talks to set up a naval base in Djibouti. All three Gulf states are trying to snap up farmland in east Africa, part of a broader effort to secure food supplies for their arid countries. Emirati-built ports could one day export crops from Emirati-owned farms.

As the Gulf states move in, however, they bring their own conflicts to a troubled region. Qatar helped to end the clashes between Djibouti and Eritrea and kept peacekeepers there for almost a decade. Then came the bust-up of 2017, when four Arab states, including the UAE, imposed an embargo on Qatar. Both Djibouti and Eritrea sided with the blockading states. Qatar pulled out its troops, and Eritrea soon seized the disputed territory from Djibouti.

Gulf states could also find themselves in competition with China. The UAE hopes to be part of China’s Belt and Road Initiative, a scheme to invest hundreds of billions of dollars in infrastructure such as roads and ports. Jebel Ali is the busiest port outside Asia, and already acts as a hub for trade with Africa. But China may want to cut out the middleman. In 2014 Djibouti tried to toss out DP World. It accused the firm of paying bribes to secure its Doraleh concession. Arbitrators in London found the claim meritless.

In February Djibouti dropped the legal niceties: it simply seized the port. The government says DP World failed to expand the port as quickly as promised. Shippers believe it took Doraleh as a sop to China, to which it is heavily indebted (see article). In July Djibouti opened the first phase of a new $3.5bn free-trade zone, set to be the largest in Africa when it is finished. Built mostly by state-owned Chinese firms, it sits next to Doraleh. DP World says the project violates the terms of its concession and is threatening to sue. The UAE helped to put Djibouti on the map. Now, ironically, it may find itself frozen out.