The Moors occupied Gibraltar for centuries until Ferdinand IV of Castile took Gibraltar in the 1309 siege. In 1333 the Moors retook Gibraltar after a lengthy siege. The Spanish regained Gibraltar in August 1462 during its eighth siege. In 1704, during the War of the Spanish Succession, a combined Anglo-Dutch force captured the town of Gibraltar.