The border of the Tagus had been overwhelmed in the second half of the 12th century because Alfonso VIII of Castile was advancing towards the Xúquer. He besieged Cuenca in 1172, but after five months of siege the caliph Abu-Yaqub forced the Castilian to lift the siege by attacking Huete. The caliph Yaqub, the philosopher Averroes, the historian Sahib as-Sala (who gives a detailed description of Cuenca) and other notable Almohads entered the city and helped the besieged. Abu-Yaqub Yússuf and Alfonso VIII signed a truce for seven years.
Cuenca, considered impregnable, suffered a long and very tough siege (for nine months) by the combined armies of Castile and Aragon, swelled by the large number of foreigners who came from the crusade that the Holy See had raised and that preached the cardinal legate Giacinto Bobone, who later became pope under the name of Celestine III.
The leader Abu Bekaa asks for help from the caliph Abu-Yaqub but he was in Africa attending to other matters and denied him help. On July 27, the besieged made an exit attacking the Christian camp with the aim of delivering a coup d'état against the king, but they only managed to kill Count Nuño Pérez de Lara. Hunger, disease and the dead from the continuous attacks of clubs and blunderbuss forced them to surrender and liberate the city on September 21, the day of Sant Mathew. The Christian army takes the citadel and the castle and, after the Muslim abandonment of the city, Alfonso VIII and his retinue triumphantly enter the city of Cuenca in October, becoming part of Castile.
Consequences
In that same year, according to Jerónimo Zurita, Alfonso II went on a military expedition to Llorca, so that the king of Murcia, who was his vassal, would ensure the tribute. On returning from this victorious expedition and being in Teruel, he gave the church of Saint Vincent to the Royal Monastery of San Juan de la Peña "pro servitio quod mihi fecisti in illa hoste de Valencia".
As a reward for Alfonso II participation in the capture of Cuenca, he and his successors were freed in perpetuity from the vassalage to Castile that had its origin in the Serón de Nágima Agreement (1158). However, this vassalage, purely nominal and circumstantial with regard to the kingdom of Aragon, never existed in truth with regard to the county of Barcelona.