THE UK and Spain are alike in their post-imperial status. As great powers they used to be splendid, but today they have come down in the world. This similarity might not yet have hit home with Theresa May, but experience of Brexit is likely to do the trick.

Spain is certainly the country more aware of its true position in the 21st century, having suffered continual and unmistakable decline since the days when it ruled most of Latin America and half of Europe. It no longer, even in its rhetoric, uses the term global to describe its aspirations. Still, the experience of empire, once acquired, is seldom lost altogether. Even today, we see Spanish diplomacy marked at its best by a mix of panache and ruthlessness which might be the envy of practitioners anywhere.

Just this last weekend we witnessed the Spanish Government delivering two painful punches, all the more so for being wholly unexpected, to the collective solar plexus of the UK Government. The first actually came from the mouth, and the pen, of Donald Tusk, the Polish president of the European Council, but we know it was the result of intensive lobbying by Madrid in other EU capitals as they all worked on their collective response to the British triggering of Article 50. In the end it contained the proviso that the particular part of Brexit involving Gibraltar must also be approved by Spain.

Let me say at once that I hold no special brief for Spain, though it is a country I love and I speak the language. But on the particular matter of Gibraltar I agree it should be for the locals to decide their own future in a democratic vote, and not what some treaty in the 18th century might or might not have said.

Gibraltarians thought they were doing just that when 96 per cent of them voted Remain in the referendum of June 24 last year. In the contrary context of Brexit, Spain is now offering them the chance to get what they then said they wanted, since for them a viable economic future cut off from the EU is hardly conceivable. But the offer comes at the price of accepting in some form, so far unspecified, the joint sovereignty of Spain. Who knows where that will lead? Well, Spain knows anyway.

But why could Theresa May not see this coming? Her letter triggering Article 50 did make one or two gestures towards acknowledging the different European interests of the different parts of the UK. Scotland, Wales and Northern Ireland all merited a mention, indeed Northern Ireland got a whole paragraph devoted to it because of the peculiar problems posed by its border with the Irish Republic. Gibraltar is not part of the UK but a British overseas territory represented in its foreign relations by the government in London, relations which have never been untroubled. Yet nobody in No 10, or in Whitehall or at Westminster, appears to have given the matter a moment’s attention.

In Madrid, they were quicker off the mark. The wily foreign minister, Alfonso Dastis knows a bit about the UK’s internal dissensions because he comes to play golf at Gleneagles. More to the point, he saw that the period in which Gibraltar had been kept off the international agenda must now reach its end. While the UK and Spain were both members of the EU, nobody in Brussels would take sides against one or the other. That changes with the UK on the way out. Dastis said in an interview at the weekend with the Madrid newspaper El Pais: “When it comes to Gibraltar the EU is obliged, as a result [of Brexit], to take the side of Spain.”

Can it really be there was not a soul in Westminster or Whitehall also able to work through this simple chain of reasoning? It’s got to the point where nothing would surprise me. The Tories leading us into Brexit are not far-sighted or generous people. They are bigoted and blinkered, their prospects bound by the M25 and their opinions formed by terror of Ukip. One of them, former leader Michael Howard, has already hinted at war as the solution for Gibraltar. Such are the depths to which we have descended within a week or so of May’s letter, with its prattle of “committed partners and allies”.

It’s a relief to turn back to an honest golfer like Alfonso Dastis and what now turns out to have been his rather skilful play on the green called Scottish independence. This is not a place where anybody was ever likely to hit par, but an eagle or a birdie, a sequence of three or four subtle strokes, would do perfectly well.

As well as an imperial past on the global stage, the UK and Spain share an internal history of ethnic fracture. So it was no surprise for comparisons to have been drawn between the nationalism of Scotland or Wales and its parallels in Catalonia or the Basque country. Spain, in fact, has much the more elaborate regime of devolution today, but is correspondingly illiberal towards attempts to alter its delicate structure.

Nobody would ever dream of depriving SNP members of civil rights, yet that is what has happened to the Catalan leader Artur Mas.

From this it might well be possible to deduce that, in order to avoid setting its own ethnic groups a bad example, Spain would discourage all signs of separatism among similar countries. It would do so in the only way open to it, by hinting that new emergent nations would have a hard time finding their way back into the EU. This is what the Unionist press in the UK said was happening, though it is difficult to pin down any statement by a person qualified to make it that there would be an actual veto from Madrid against the hapless applicant: just winks and nods that misled not only nationalists in Scotland but also Unionists in London.

Suddenly we see it was all smokescreen. When Dastis briefed the European press last week, he made clear that Brexit had pushed Gibraltar to the top of his agenda, right into the space left there by the heedlessness of the UK Government in its small-minded indifference or stupid laxity.

Scotland was now a sideshow, though a useful sideshow: “We don’t want it [Scottish independence] to happen,” Dastis said. “But if it happens legally and constitutionally, we would not block it. We don’t encourage the break-up of any member states, because we think the future goes in a different direction.’ It is not clear if the same qualification applies to a former member state, but in any case we now see the UK’s centrifugal forces strengthening even before it reaches the point of Brexit.

The situation in Northern Ireland points to a slow but steady detachment of the province from the ties that at present bind it. The Irish model of open borders could easily accommodate, if extended across the whole of the British Isles, an independent Scotland. Only the position of Gibraltar, created for it by the government in London, is not to be envied.

But there we are: a week or so after Article 50 was triggered, and already the UK Government is exposed as woefully inadequate to the basic task of protecting the interests of people it is supposed to represent. The trouble arises above all from its own failings, and its myopia towards the demands of anything but hard Brexit. “The choices we make determine the character of our nation,” May said in her letter. For once, I could not have put it better myself.