Castillo de los Condes de Cabra traces its origins to the 9th century Emirate of Córdoba, when it served as an Arab fortress crucial to military operations in the region. The castle witnessed the Battle of Cabra in 1079, where the Cid Campeador participated in conflicts between rival taifas. Elevated to the residence of the Counts of Cabra in 1455 by Henry IV of Castile, the fortress became an important symbol of dynastic power, holding notable prisoners including the last Nasrid emir Boabdil after the 1483 Battle of Lucena. In 1635, the Count of Cabra established a Franciscan convent within the castle grounds, completed in 1649. Sold to the Escolapian nuns in 1899, the complex continues functioning as an educational center; in 2022, the crypt of the Counts of Cabra was discovered beneath the convent.