The castle was constructed during the 8th and 9th centuries, during the period of
Muslim Iberia, as the central place in territory that was primarily agricultural, and necessary to protect its population. In 1031, after the loss of
Córdoba to the
Almoravid dynasty, the king of Badajoz opted to transfer to
Alfonso VI of León and Castile a few territories on the Iberian peninsula (among them Sintra) in order to gain an alliance with the Christian king. An 1830 lithograph by Burnett immortalized the chapel's place in the Castle. At the end of the 19th century the administrator of the Forestry Service, Carlos de Nogueira, authorized several projects in the castle and in the chapel. In 1939 the DGEMN became involved in the reconstruction of the castle walls, in addition to the lateral door of the chapel. With an eye towards a fledgling tourist market, in 1954 a few of the cliffs were cleared to establish a picnic area near the castle, and in 1965 a transformer was installed to provide illumination. In 1979 archaeological excavations in the Chapel of São Pedro were begun by the cultural services of Portugal, which discovered the existence of medieval funerary tombs, dating to the turn of the 13th century. A dispatch by the Ministry of Culture, on 26 June 1996, declared the area of the Castle as a zone of special interest (). During the summer of 1986, scouts were involved in projects to consolidate the walls with cement and clean the grounds, supported by the CMS. In 2001 there were various interventions associated with cleaning the property, clearing undergrowth and forest overgrowth, and the installation of an electrical box along one of the walls. ==Architecture==