(Bloomberg) -- The Spanish and Moroccan governments vowed to deepen diplomatic and trade ties, drawing a line under years of bitter disputes that threatened to undermine security and energy interests.

Concluding his two-day visit to the Moroccan capital, Spanish Prime Minister Pedro Sanchez announced more than 20 agreements, including an 800 million-euro ($880 million) credit line to bolster investment in a country he describes as a “gateway into Africa.”

“The war in Ukraine and the instability that is taking place in many parts of the north appeal to our shared responsibility to defend a rules-based international order,” Sanchez told reporters in Rabat. He was flanked by his Moroccan counterpart, Aziz Akhannouch.

The first Moroccan-Spanish summit in eight years is the latest sign of warming ties and comes as countries across Europe attempt to win over allies in North Africa to bolster their energy supplies and security following Russia’s invasion of Ukraine. 

Trade between the two kingdoms includes fresh produce, automobiles and refined oil products, while some Spanish apparel companies reply on Moroccan textile producers for manufacturing.

Separated by less than 10 miles of sea at the narrowest point, Spain and Morocco have for decades feuded over maritime borders, the status of Spanish exclaves bordering Moroccan territory and the fate of Western Sahara, a disputed territory Spain once ruled and that Morocco annexed in 1975.

Diplomatic Row

Sanchez’s surprise move last year to back Morocco’s proposal to grant limited autonomy to Western Sahara helped defuse a diplomatic row that arose in 2021 when Madrid allowed the leader of an armed independence group be treated at a Spanish hospital. Thousands of people subsequently tried to cross into the exclave of Ceuta, with Spanish authorities accusing Morocco of easing border controls in retaliation.

Still, both countries have yet to agree on sensitive issues such as how to regulate migration flows and the full reopening of trade with Ceuta and the other Spanish exclave of Melilla. Human-rights groups have urged authorities to address the abuses to Moroccan women involved in contraband of goods from the areas. 

Irregular migrant flows to Spain from Morocco dropped by more than a third since the rapprochement last year, while the stream of people trying to reach Europe through other routes has risen, according to Spanish officials.

The death of 23 people during an attempted mass crossing to Melilla last year brought renewed attention to the border policing as well as the growing numbers trying to escape poverty and climate change. 

©2023 Bloomberg L.P.