 A Moorish town occupied the strip of land along the west of the peninsula between the sea and the Rock.The northern approaches to the town were defended by a castle on the slopes of the rock, from which walls built in the Middle Ages ran down to the shore of the Bay of Gibraltar.A tower was built at the end of the wall by the Spanish after Ferdinand IV of Castile took Gibraltar from the Moors in 1309.