The monastery of San Juan de la Peña is tucked under an overhanging rock. Though the cloister dates to the 12th century, the monastery is much older. Like a number of other medieval monasteries in Spain, it formed around a reclusive hermitage inside of a cave. Later buildings grew up around it, emerging in stages from the 10th century through the 18th.