The Spanish claim to Gibraltar, which was ceded to the United Kingdom exactly three centuries ago, is based upon the position that Gibraltar is Spanish territory. The problem is, Spain continues to retain two North African colonies from its past, the exclaves of Ceuta and Melilla, which Morocco has repeatedly laid claim to, asserting that both cities are Moroccan territory. Spain has pointedly ignored those claims.
Why does Spain retain these remnants of its African colonial possessions, you say ? Because both cities, which are overwhelming populated by ethnic Spaniards, have stated that they want to continue to be part of Spain. That is, pursuant to the United Nations Charter, the Right of Self-Determination. Those people have that right under established international principles.