In 1999, Vladimir Putin was angling to become president, a complex task considering the amount of money and violence in Russian politics at the time. He needed to talk to all the players and needed to do so somewhere unobtrusive, so he convened a meeting at an oligarch’s Mediterranean villa. This, however, caused a problem: how could he travel to southern Spain without alerting the Spanish, who might monitor the conversations and learn what was going on?

Fortunately, there was a solution: Gibraltar. The then-FSB chief flew into the British territory, hopped on a boat and entered Spain illegally, on perhaps as many as five occasions. Russian spooks are not the only thing Gibraltar has smuggled across the border. According to media reports quoting a confidential EU investigation, the Rock imported 117m packets of cigarettes in 2013, enough for every Gibraltarian to smoke almost 200 a day. The cigarettes didn’t stay there, however; they, like Putin, were passing through. This epic smuggling operation may have cost EU countries €700m in lost tax revenues over four years.

Britain’s response to Spain’s demand that it have a say over how Brexit affects Gibraltar has been one of almost universal fury, but it shouldn’t have been. If you imagine that, owing to some ancient treaty, Spain had a base in Dover, from which Russia’s chief spy had repeatedly sneaked into Kent, and smugglers had flooded the country with cheap fags, massively undermining our tax base, we would be pretty cross, too. It’s something of a wonder that Spain has put up with it for so long.

Gibraltar hasn’t always been this way. It used to be a naval garrison blockaded by Spain and with almost no links to its neighbours at all. Naval spending made up almost two-thirds of Gibraltar’s economy in the 1980s, but the money dried up with the end of the cold war and the Rock had to diversify. Like most of the other remaining British colonies, it did so by aggressively undercutting the rules and taxes of its neighbours. In time, it found a comfortable niche enabling business projects that were too dodgy for Jersey or the Isle of Man.

There are more than 60,000 companies registered in Gibraltar (two for every resident) and they routinely pop up in bribery scandals all over the world. In 2005, telecoms giant Vimpelcom wanted to expand into Uzbekistan and, needing to gain the government’s approval, cut in Gibraltar-registered Takilant Ltd for tens of millions of pounds.

Takilant was, in reality, just a front for Gulnara Karimova, the daughter of the Uzbek dictator, Islam Karimov, and a would-be pop star referred to by US diplomats as “the single most hated person in the country”. Other scandals facilitated on the Rock have touched on Nigeria, Congo, Ghana and elsewhere.

It is a tribute to Gibraltar’s PR operation that more people in Britain don’t realise what is going on. Gibraltar is not part of the UK, can set its own tax rates and has been using them to aggressively undermine us as much as, if not more than, everyone else. A Gibraltarian growth industry in recent years has been online gambling, with most of the big UK operators – William Hill, Ladbrokes, Bet365 – moving their operations to the Rock.

The Treasury did initially try to keep betting onshore by offering them a tax break, but that wasn’t enough and they relocated en masse. There are now 30 gaming companies in Gibraltar, with the tunnels used in the Second World War to plan Operation Torch housing servers powering their websites. It’s not hard to understand why they’re there: it is considerably more profitable to run UK gambling operations if you don’t have to pay UK taxes and the British Treasury has missed out on millions of pounds as a result.

None of this matters, the Rock’s many defenders say: Gibraltar is loyal, it guards the gates to the Med, it loves Britain and the Queen. This is a curious kind of love, though; like a kid who visits his gran every weekend, just so he can nick her pension. It’s not a fashionable opinion to have right now but, when it comes to Gibraltar, the Spanish have a point.

Oliver Bullough’s forthcoming book, Moneyland, will tell the history of the global super-rich