Gibraltar had been a rock of contention for ages prior to the British arriving in 1704, when they shelled the fortress into submission. By this stage the Moors had already been here for the best part of seven hundred years (with a brief gap) until the Spanish regained the territory in the late-15th century. On the European side of the narrow straits that separate Europe from Africa and the Mediterranean from the Atlantic, the fortress was always of great tactical importance. Under Moorish rule Gibraltar operated as the gateway to Europe for occupying forces, and under British rule it was still in the thick of things. The port was embargoed by the French Navy in the 18th century and it was to the Rock that the body of Lord Nelson was first brought following his death at Trafalgar.
The World Wars really defined Gibraltar. Having been a vital naval port in the First World War, in the Second the Rock was threatened by General Franco, who sided with the Axis countries. Immediately following the war, tension between the UK and Spain over Gibraltar's sovereignty led to the border being closed in 1969. It remained this way until the 1980s.
It is this relatively recent history that adds to Gibraltar's allure. Although isolated from its colonial parent, and being genetically a cosmopolitan mixture of several Mediterranean cultures, it remains "British" with a steadfastness that borders on the obsessive.
For people from the UK in particular, Gibraltar is a fascinating anachronism, much like Cuba is for Americans. It's like stepping backwards in time to a Britain of 30 years ago. For everyone else it is a quirky place where phone boxes are strangely robust and red, policemen wear impractical headgear and wild apes stroll around town (not quite so British that last one).
Plenty of people pop over the border from Southern Spain, happy to have a brief glimpse of this unique piece of colonialism gone literally mad. However, it's just as worthwhile to come to Gibraltar for its own sake, with plenty of natural and cultural charms.