Get Brexit Done” was the Tory general election slogan in 2019 but the truth is that, even after Britain formally completed the process and left the European Union on 31 January 2020, there was still substantial unfinished business.

One of the more intractable problems was Gibraltar, a British overseas territory but also inside the EU. Talks on its future status have dragged on until now, with the conclusion of the “political agreement” on clearing up the details and the signing of the Gibraltar section of the EU-UK Trade and Cooperation Agreement. But not everyone is happy.

Why was there a Gibraltar problem?

As with Northern Ireland and Ireland, it was agreed in principle that there should be no “hard border” between Gibraltar, which now finds itself outside the EU, and Spain. But how to control movement of goods and people without checks? Tobacco smuggling was a particular source of arguments. The additional complication was that Spain is a member of the Schengen Area, which has no passport controls at all at borders with other members.

Important military facilities on Gibraltar also need to be protected, as do reasonable relations between two Nato member states. As with Ireland and Northern Ireland in the more distant past, there is also the awkward fact that Spain did not accept British sovereignty over Gibraltar – unfairly ceded in the Treaty of Utrecht in 1713, according to Madrid. This constitutional issue had poisoned British-Spanish relations for decades.

Why has Gibraltar taken so long to fix?

Early in the Brexit talks, in 2017, the EU granted Spain “special status” over Gibraltar, in effect a national veto over whatever the EU and UK negotiating teams came up with. British, Spanish, and indeed Gibraltarian sensitivities proved irreconcilable, but, unlike Northern Ireland, the problem was small enough to shelve.

Now it has been ingeniously settled. (The great historical irony is that, when the UK was an EU member state and Spain was seeking to join in 1984, the British were able to extract concessions from Madrid about an open border, the Spanish having previously sealed it to undermine Gibraltar).

Is Gibraltar still British?

Yes, but with full internal self-government and, as with the Falklands (but arguably not the Chagos Islands) the UK has given the government of Gibraltar the effective right to say no to any deal.

The main change is that there will additionally be Spanish border officials operating at the seaport and at Gibraltar International airport, and there are extra restrictions on entering Gibraltar if a British passport holder has already spent 90 days in the Schengen zone over a 180-day period. But this can be treated as a rule imposed by the autonomous administration of Gibraltar. It is analogous to the uncontroversial presence of French border officers at St Pancras International.

Has Spain given up its claim to Gibraltar?

No, but the British government says that there will be “a clause agreed by all sides which makes explicitly clear that the final treaty does not impact sovereignty”.

What do the Gibraltarians want?

To have their cake and eat it. The last referendum on their relationship with Spain was in 2002, when the Blair government wanted a much stronger bond with Spain for geopolitical purposes and sought to remove this obstacle. Asked if they approved of the principle that Britain and Spain should share sovereignty over Gibraltar, they rejected the idea by 99 per cent. On the other hand, in the 2016 Brexit referendum they voted Remain by 96 per cent to 4 per cent. So they know their minds, sort of.

Are the Gibraltarians happy now?

Very. The chief minister of Gibraltar, Fabian Picardo, declared: “I’m delighted we have finalised a conclusive political agreement which will bring legal certainty to the people of Gibraltar, its businesses and to those across the region who rely on stability at the frontier.”

Who is unhappy with the Gibraltar agreement?

The usual suspects, and even then not radically so. Nigel Farage, who once wanted Gibraltar to become part of the territorial UK itself (and contrary to the Treaty of Utrecht), now expresses mild disappointment that it is “a little bit less British”. Even Priti Patel, that most vociferous defender of the British Empire and currently shadow foreign secretary, merely confines herself to warning: “Gibraltar is British, and given Labour’s record of surrendering our territory and paying for the privilege, we will be reviewing carefully all the details of any agreement that is reached.”

Does Gibraltar’s status matter?

Much more than it might seem. As part of a steady process of rebuilding relations, resolving problems and achieving a mutually advantageous Brexit “reset”, Starmer’s government, including the foreign secretary David Lammy, has proved astonishingly successful. The prize is a European defence partnership, with British participation at every level, including industrial and procurement. A couple of Spanish border guards at Gibraltar seems a small sacrifice to make for the security of Britain’s base and indeed the whole continent; and Spain needs to be encouraged to contribute more to Nato and collective European security.