The castle's history started in the Middle Ages when a chapel dedicated to Our Lady of Pena was built on the top of the hill above Sintra. According to tradition, construction occurred after an apparition of the Virgin Mary. In 1493, King John II, accompanied by his wife Queen Leonor, made a pilgrimage to the site to fulfill a vow. His successor, King Manuel I, was also very fond of this sanctuary and ordered the construction of a monastery on this site which was donated to the Order of Saint Jerome. For centuries Pena was a small, quiet place for meditation, housing a maximum of eighteen monks.