The walled enclosure dates back to the Middle Ages. The wall controlled the entrance of provisions and merchandise, and also isolated the city, guarding it against the potential outbreak of a plague or epidemic, in addition to its obvious defensive function.
It is shaped like an irregular rectangle, with crenellated towers and round turrets. It has nine gates that provided access to the city, of which the most spectacular is Puerta del Alcázar (Gate of the Fortress). It was declared a National Monument in 1884.