In 886 with Emir Mohamed of Cordoba dead, Cabra revolted in favour of Omar, son of Hafsum, but his successor, Almondir, sent in the cavalry who took the castle and the fort. In 1226, Alfonso the Battler conquered it, but with Castle Anzur collapsed, he abandoned it. In 1240, it was conquered by Fernando III of Castile, who donated it to Alonso Rodríguez of León. On February 5th, 1258, Alfonso X of Castile signed a charter to grant Cabra to the Council of Cordoba. In 1288, Sancho the Brave revoked this concession, giving it to his son, Pedro de Ledesma, who traded it in for the village of Santa Olaya to the Order of Calatrava, entrusted with Cabra, and whose first master was Juan Núñez del Prado. In 1328, Alfonso XI of Castile ordered a new castle and fortifications to be rebuilt. According to Ramírez de Arellano, the exterior towers may be from this period. In 1331, Pedro Díaz de Aguayo handed it to the people of Granada, who demolished most of its towers and walls. In 1445, Henry 4th of Castile donated the fortress and castle, with the title of Count, to Marshal Diego Fernández of Córdoba.