Spain argues that the territory’s status is a colonial relic, pointing out that the same treaty also gave Britain the island of Minorca, which it returned to Spanish control more than a century ago. Britain says it is merely standing by the wishes of Gibraltar’s residents, who in a 2002 referendum overwhelmingly rejected the idea of sharing sovereignty with Spain.

The colonial reference “says more about Spain’s anachronistic obsession with Gibraltar than it does about anything else,” the government of Gibraltar said in a statement. “This is totally out of place in the modern Europe of today.”

European Union membership has certainly had advantages for Gibraltarians. Under terms set when Britain joined the bloc in the 1970s — while Spain was still under the dictatorship of Gen. Francisco Franco, and more than a decade from becoming a member itself — the territory has special status as a free port, excluded from Europe’s customs union. That allows it to build up its trading and services activities on advantageous transit and taxation terms.

Ships refuel and change crews off Gibraltar’s coast to avoid docking costs, and the territory’s low-tax regime (also criticized by Spain) has allowed its economy to grow rapidly by attracting industries like online gambling. About 10,000 Spaniards now work in Gibraltar, commuting daily from what is one of the areas of southern Spain with the highest unemployment rate.

When Britain held a referendum on European Union membership in 2016, Gibraltarians again formed a solid consensus: 96 percent backed remaining in the bloc, partly because of concerns that they could become a pawn in a larger European negotiation involving various frontier issues. They fear that Spain could reintroduce border checks that would effectively leave their tiny territory isolated and economically squeezed.