The Lilliputian row over Gibraltar, less than half the size of David Cameron's constituency, is surely the most perfect example of how not to do diplomacy. Listening to British, Spanish, Gibraltarian and Andalusian protestations over how their position is right and everyone else is wrong can only generate despair at how, given the world's more pressing problems, the British and Spanish press and political leadership can have devoted so much time and so many words to this tiny promontory at the southwest corner on Europe.

David Cameron and Mariano Rajoy are more similar than they they care to admit. Both are weak national leaders without real control over parliament or the flow of politics. Both are fed up with the EU. Both have terrible youth unemployment problems. Both have restless sub-region-nations, Catalonia and Scotland, which do not want fully to be integrated into the bigger entity of the UK or Castilian Spain. Both once had great empires and dreams linger on with monarchical trappings. Both have huge problems with party financing though Rajoy does not have the luxurious corruption of being able to turn political donors into legislators to buy their silence. Both are considered a nuisance in the United States which has recently signed a long lease on a major naval base at Rota just up the coast from Gibraltar. Both have odd colonial enclaves like Ceuta and Melila for Spain in Morocco or Gibraltar and the Falklands for Britain. Both have rotten banking systems which were allowed to go bust because ministers and officials in London and Madrid end enjoyed a permanent siesta while the banksters were building their Ponzi schemes.

Spaniards and Brits get along fine. Hundreds of thousands of Brits treat southern Spain as their sunshine home much as Detroit and Pittsburgh retirees head for Florida. Spaniards are a key to English soccer success and in contrast to views on France or Poles, there is no Hispanophobia to be seen in Britain.

So why this absurd dispute, two bald men fighting over a comb, to borrow Borges' metaphor from the Falklands conflict? The answer is that British foreign policy under Cameron and Hague has moved from interests to images. Nearly all of the government's foreign policy initiatives since May 2010 have been about image. The endless rows over Europe culminating in the offer of a referendum are about internal Conservative Party problems, not real UK interests. The grandstanding behind Sarkozy over Libya has led to permanent instability in North Africa and a violent, out-of-control conflict. Half promises to arm anti-Assad jihadis are attempts to portray Britain as determining Middle East developments. The reduction of the armed services to nugatory levels has dismayed Washington which sees Cameron's Britain as no different from other weak European powers. Where Cameron and Hague could have been strong, such as by standing up against Putin over human rights abuses including the killing of the British-linked lawyer, Sergei Magnitsky, they have been weak.

Britain has lost huge capital in India and China by the bureaucratic incompetence of issuing visas to business leaders, wealthy tourists, and well heeled students. The EU's Schengen visitor's visa is much more attractive. Again, sensible British foreign policy is sacrificed to appease the Daily Mail, UKIP, the BNP and ugly outfits like Immigration Watch.

Foreign policy requires education, explanation and encouragement of sensible public opinion. But instead we have day-to-day media management all predicated on museum concepts that Britain punches above its weight in world affairs, has a special relationship with America and has no need for the EU.

To be sure, inter-state relations are much more about public opinion than what Palmerston called interests. He, after all, gave us the Olympian pomposity of his 'Civis Britannicus sum' speech as mid-19th century Britain readied itself to bombard Athens over the arrest of a dodgy trader with the loosest of links with Britain. Ahead of the WWI anniversary it is worth re-reading Foreign Secretary Edward Grey's speech to the Commons late in July 1914 when he said again that 'public opinion' was what would decide whether Britain went to war or not.

Public opinion is often a good judge. Many were outraged at the cowardice of the John Major Government's refusal to intervene to stop genocidal mass murder in the Balkans. Even more said intervening in Iraq was wrong even if it meant leaving a psychopathic mass murderer of Muslims in power. In both cases political leadership might have listened.

Public opinion also needs to be educated about Gibraltar; not to give it up, which is neither likely to happen nor especially desirable any more than Spain will give up Ceuta or Melilla, France will incorporate Monaco or Andorra will dissolve into Spain. These leftovers of old Europe have a charm and should be treated as curiosities, not causes of conflict.

But they do need constant management and some sense of what works. They also need some cross party consensus. In the last big row over Gibraltar a decade ago the Conservative Party decided to play the Gibraltar card against Jack Straw and Peter Hain in their sincere but poorly judged effort to 'solve' the problem. The current weakness of the ruling Partido Popular government in Spain encourages ministers to make bombastic attacks against Gibraltar. Equally Hague has to reveal whether he authorized the dumping of several dozen giant concrete blocks with metal rods and hooks sticking out to destroy the legitimate fishing activity of low molluscs small boats from poor Spanish villages close to Gibraltar. Britain is right to say Gibraltar's status stays as it is but wrong to allow free reign to small town politics in Gibraltar to indulge in endless provocations against the impoverished Andalusian hinterland.

When rightists temporarily overthrew Hugo Chavez in April 2002 the United States immediately cancelled a huge naval exercise with the Venezuelan navy which had been planned for more than a year at a cost of US $1 billion. Anything rather than send warships to the region. It beggars belief that London still allowed what El Pais called 'una ponderosa flottta de guerra' ( a powerful battle fleet) to the seas near Gibraltar. Ships have rudders and captains can be told by ministers in a democracy to steer elsewhere.

It is this lack of sensitivity that underlines the Cameron-Hague tin ear to foreign relations since 2010. The Gibraltar problem can be managed. It requires officials from Gibraltar, the Andalusian regional government, London and Madrid to sit around a table and find solutions to restore the status ante quo and have a permanent contact mechanism to head off problems before they make headline.

The Spanish Prime Minister Mariano Rajoy has just made that suggestion after meeting the King of Spain who almost certainly told him to grow up. Perhaps the Queen of England can have a similar word with the UK prime minister. The Gib row is lose-lose politics for both nations. It it time for some grown-up diplomacy.