In Gibraltar, said chief minister Fabian Picardo, children learn history fast. "They can say 'the treaty of Utrecht' when they are around a year old," laughed Picardo, an Oxford-educated socialist with a picture of the Queen in his office. "We start them young."

It was that agreement, signed in 1713, that granted the 426m-high rock jutting out where the Mediterranean meets the Atlantic to the British "in perpetuity". And as Gibraltar swathes itself in red, white and blue to celebrate the Queen's jubilee, it is revelling in its reputation for being "more British than the British".

"It's about the symbolism, really," said taxi driver Eddie Castle. "We do like to irritate the Spanish when we can. But they get their own back: whenever there is a row, they get their own back by making things very difficult for people at the border."

The queues of cars waiting to cross from the tiny 2.6 sq mile territory into Spain have lengthened dramatically in the last week, as Spanish border patrols have been ordered to make things more difficult for motorists and workers, increasing security checks in a move condemned by Picardo as "childish".

The latest row in the centuries-old fractious relationship between Gibraltar, London and Madrid is, as many have been over the years, about royalty.

On Friday, the Queen held a jubilee lunch for the world's monarchs at Windsor Castle – the largest gathering of crowned heads in over 50 years, with 24 kings and queens in attendance. The one notable absentee was Queen Sofía of Spain, distantly related to both the Queen and Prince Philip, who pulled out after her government said her attendance would be "inappropriate" in view of a forthcoming trip to Gibraltar by Prince Edward and his wife.

The British ambassador was called into Spain's foreign ministry to hear of the ruling party's "disgust and upset" at the Count and Countess of Wessex's visit. So it must have been with a certain mischief that Picardo told the Observer it was a "great pity" that the Queen herself was not also coming to the territory.

"She would be very welcome here. I like to think she has not come because she has been so busy. In Gibraltar, people will celebrate the jubilee whether they are from republican families or monarchist families. It's not really about that here. The royal family transcends those arguments – the Queen is a figurehead of Britishness, an important symbol for us, and I say that as the grandson of a republican."

It was the Queen's visit in 1954 that triggered General Franco's anger at the British retention of a symbol of Spanish nationalism. He called it a "dagger in the spine of Spain" and in 1969 launched the blockade of the Rock that lasted until 1985. The intention of Charles and Diana to begin their honeymoon there in 1981 resulted in the King of Spain boycotting their wedding.

"We are not an island, but we consider ourselves one," said Picardo, who believes many of the rows have been diversionary tactics. "There are tensions: generally they arise when the Madrid government has trouble and strife it doesn't want people to concentrate on. I have great sympathy for them at the moment with the financial crisis.

"When we say here 'the Spanish' in a derogatory fashion, we tend to mean your chap in Madrid, the institutions; we have no problems between ordinary people, at the human and personal level."

But there is a problem at sea: a row over Spanish fishing boats in effect breaking Gibraltar's "no net" marine protection laws while fishing in waters that Spain claims for its own. The row has had politicians scurrying back through old treaties and legal entitlements and citing everything from Napoleonic "cannon shot" rules to UN conventions, but Picardo says he is now a "hair's breadth" from creating a mechanism to try to resolve the dispute with a cross-border working party.

"We don't believe that we should just turn a blind eye to that. If we accommodate these fishermen, then we would have to change our law. Spain has 8,000km of coastline, we have three," he said.

In the Gibraltar Bookshop – its windows a tribute to the Queen's 60-year reign and displaying a poster declaring "Keep Calm and Rule Britannia" – owner Jackie Scriven is looking forward to the jubilee street party and other celebrations planned. "We have to have the Spanish respect us, from our territorial waters to our Queen," she said. "When we remember what the Spanish did to us during the blockade, it was horrendous. They didn't let us have water, blood supplies, even the sacramental wine for the churches. We had to watch the ships sailing past us with food for Morocco, we couldn't get in or out except by boat.

"We've been British for 300 years and we are really loyal subjects. Even the younger generation are enthralled: more and more they are speaking English on the streets."

The economics of Gibraltar have little to do with patriotism. Its tax status means the territory has more registered companies than inhabitants. Marriages can be arranged quickly for non-residents – John Lennon married Yoko Ono here and Sean Connery married here twice – and it is a hub of offshore banking and online gambling, but Gibraltar has the air less of a European Las Vegas and more of a Torquay-by-Andalucía. Its efforts to establish itself as a telecommunications base have been hampered by Spain's refusal to recognise its dialling code.

Tentative efforts by British leaders from Margaret Thatcher to Tony Blair to broker a joint sovereignty deal have been foiled by two no votes in referendums, in 1967 and in 2002. It remains UK policy that Gibraltar's status will not change without its people's consent.

Meanwhile the cold war with the mainland goes on. Ships that have visited Gibraltar are not allowed to go into Spanish ports. Spain does not recognise the Gibraltar government and refers to Gibraltarians as "transients", on the grounds that the legitimate population was expelled in the 18th century.

Out on a main street bristling with bunting – where pubs sell British grub and M&S advertises "UK prices" next to little shops selling T-shirts saying "Proud to be British" – political views are generally relaxed. Schoolgirls in white and burgundy uniforms crowd into Top Shop chattering in a mix of Spanish and English. "I'm Gibraltarian, or maybe English, both," said Catherine, 14. "My dad would kill me if I didn't say British but I think, for me, Gibraltarian," said Rose, 14.

"Are you kidding me?" said a 15-year-old boy in designer sunglasses with a Spanish surname, when asked if he feels linked to Spain. "Nobody hates them or anything, but it's a different world in Gib." And as far as the majority of the inhabitants are concerned, it's a case of bring on the jubilee.

• This article was amended on 23 May 2012. The original referred to Gibraltar as an island. This has been corrected.