TheshortansweristhataftertheReconquista, whenSpainreconqueredtheIberianPeninsulafromtheMoors, theSpanishtookitjust a littlefurtherandinvadedAfricaandtookover a bunchofcities.
Thiswillcreate a landborderbetweentheEUandtheUnitedKingdominmainlandEurope, andprobablyseverelylimittheabilityofpeopletomovebackandforthfromGibraltarcomparedwithtoday.
Theislandis a partofSpainforsixmonthseveryyearand a partofFrancefortheothersixmonthscompletewith a ceremonythatformerlytransfersthesovereigntyoftheislandbetweenthetwocountries.
Anotherconsequenceofthistreatyin 1659 wasthissituation a littlefurthernorthintoFrance, whereyoucanfind a tinychunkofSpainthatiscompletelysurroundedbyFrance.