In the latest ratcheting up of tensions over Gibraltar, the Royal Navy has ordered a Spanish warship out of the peninsula’s disputed territorial waters. Though the incident was relatively minor, it highlighted the conundrum facing Gibraltar after the triggering of article 50. Then again, the status quo was never satisfactory, even pre-Brexit. This is an issue which, as Europe minister, I tried to resolve 15 years ago.

The privileged VAT-free status of “the rock” outside the European customs union but inside the single market has long been anathema to Spain, which has repeatedly alleged smuggling and money laundering.

Spain resents the loss of territory nearly 2,000 miles from Britain and physically connected by an isthmus to its mainland. How, Spain asks, would Britain feel if the war of the Spanish succession 300 years ago had gone the other way and, under the Treaty of Utrecht, it had instead grabbed the Isle of Wight? Britain would surely have had an equivalent claim to sovereignty.

Yet today’s Gibraltarians have rights too. Their historic predicament is not their fault, and successive British governments have honoured Harold Wilson’s 1969 pledge to grant them a vote on their future.

Attempting to resolve this intractable dispute as Europe minister in 2001-02, I negotiated on a “co-sovereignty” deal with Spain – steadfastly supported by Prime Minister Tony Blair and the foreign secretary, Jack Straw. It was finally agreed after nine months of negotiations, and it remains on file in the foreign offices of both London and Madrid.

Actually, it was the then chief minister of Gibraltar, Peter Caruana, who first suggested I look at Andorra’s status, essentially one of co-sovereignty between Spain and France, expressed through the king and the bishops, with its own autonomy and representation in the European Union.

The co-sovereignty deal was and still could be a win-win for all parties to the dispute. The only concession Gibraltarians would have to make is a Spanish flag flying on the rock alongside a British one. Their cherished British citizenship, traditions, customs and way of life would be unchanged – except for the better because being under siege from Spain would disappear. Pints of beer would still be served in British-style pubs. Gibraltarians would keep their institutions – self-government, an elected house of assembly, courts and police service.

Indeed, our deal gave Gibraltar much greater self-government and democratic autonomy, by abolishing the colonial trappings of its governor general acting on behalf of London. It also removed many obstacles that affected normal daily life – such as border controls, restrictions on telephone access, and the lack of easy diversions to Malaga of incoming plane flights to Gibraltar airport in bad weather.

The Spanish government in 2002 readily agreed to that, insisting it had never been interested in controlling Gibraltar, just pursuing its sovereignty claim. The deal meant massive jobs and prosperity benefits too, including turning a new merged harbour with Algeciras into the most important container and harbour port in southern Europe, ideally placed for both the Atlantic and Mediterranean.

Moreover, three of our important “red lines” were eventually conceded by Spain. First, full British jurisdiction and full British operational control over Gibraltar’s Nato defence base, which contains some sensitive facilities. Second, no “slippery slope” to full Spanish sovereignty. And third, no identification of Gibraltar in the Spanish constitution as a defined region.

Finally, on 18 April 2002, and after six hours of tough exchanges in Madrid, Spain’s Europe minister, Ramón de Miguel, and I, with our senior officials, shook hands – not quite believing our governments had managed to come together on Gibraltar for the first time in 300 years.

However, there was a fatal twist when our plane landed in London. I switched on my mobile to discover our deal, approved at every stage by our respective prime ministers and foreign secretaries, had been tantalisingly vetoed while we were in their air when Spain’s prime minister, José María Aznar, got cold feet at the last moment.

But, today’s Conservatives, please pay heed. Though co-sovereignty was only officially endorsed by our Labour government in 2002, former Tory Europe minister Tristan Garel-Jones has confirmed that “this is what we were trying to do under the Thatcher and Major governments”.

In 2002 our new deal for Gibraltarians was roundly rejected in a referendum. They were stuck, wanting to remain where they were, yet hating where they were. One of their cheerleaders, rightwing Tory backbencher Andrew Rosindell, desperately asked: “Why can’t you just reintegrate Gibraltar and make it part of England?”

Their stance has echoes of hardline unionists and loyalists in Northern Ireland, who for generations said “never, never” to sharing sovereignty with republicans and nationalists – until they were finally persuaded it was actually in their own interests to do so.

Resurrecting co-sovereignty today would doubtless provoke a similar reaction on the rock even though it’s in a much worse place than 15 years ago because of likely exclusion from the EU against its will. Yet it would give Gibraltarians much more freedom and security than ever historically.

It’s surely time to dust down those files, and for politicians in Gibraltar, Britain and Spain to show some real leadership.