During the Muslim period, high walls protected the citadel and the medina.In 1268, Afonso III of Portugal expanded the walls and made few structural changes. In the courtyard of the castle, there is a covered corridor or a tunnel leading to lower sections of the castle. A staircase leads to the upper section (ramparts) of the castle where three towers still stand today.