That question is likely to become more than academic pretty soon. To be honest, I do not know enough about the history of Gibraltar to make an informed opinion on the subject.
From what I do know of it, I would say that Spain has a better claim on it than does Britain.
Okay, here’s one closer to home you might know about. Cuba wants Guantanamo back. They claim that the treaty signed with the previous government is null and void, they refuse to cash annual rent checks and have repeatedly demanded the US leave what they consider Cuban soil. If they begin shelling the fort, are they justified? Is it an act of war?