ألفونسو السادس ملك قشتالة
In the early 11th century, the Caliphate of Córdoba broke into several rump states ("taifas"). Cuenca was ruled by the taifa of Toledo—possibly the largest one—whose jurisdiction roughly spanned across the bulk of the Middle March of Al-Andalus. In 1076, Cuenca was besieged by Sancho Ramírez of Aragon, who failed to conquer the place. In 1080 King Yahya al-Qadir of Toledo lost his taifa, and his vizier signed in Cuenca a treaty with Alfonso VI of León and Castile by which he ceded him some fortresses in exchange for military help.