As part of the settlement of the War of the Spanish Succession, the Treaty of Utrecht agreed that Gibraltar would be British. We refer to it as a "British Overseas Territory". So, it's British.
It's understandable that this is a bit of a thorn in the side of Spain. Well, tough. It's British.
When the UK negotiates terms and conditions for trade with the EU, all of the EU members have to agree to whatever is proposed. Unanimously. This means that, for example, Slovenia has a veto. And so does Spain.
So how will we get Spain to agree to what we want? Well, just like every other country, we have to make them an offer that they're happy with.
And if Spain wants to make some new arrangement over Gibraltar a requirement, they can do that.
And we want (I think) pretty much the same access to the EU Single Market as we had back in the old days, when we were a member of the EU.
So what are our options?
Well, we can walk away from any trade deal. Some people seem to think that this will hurt the EU more than it would hurt us, but they're dreaming. We need to export to Europe, and a favourable trade deal, such as we had before Brexit, is very desirable.
Or we can bribe each EU country that threatens to veto, with something that they want. 45 million voters outvote 30,000.
If I were one of the 30,000 people living in Gibraltar, I'd be brushing up my Spanish, because this isn't 1982, Mrs May isn't Mrs Thatcher and the Royal Navy doesn't have any aircraft carriers.