Excerpts from Books and Wikipedia
"Ferdinand had not taken Cordoba on his own, nor was he aided by Christian forces from abroad. Rather, Ferdinand had subjugated Cordoba in the old-fashioned Andalusian way, in an alliance with a Muslim. After the Almohad defeat of 1212, taifalike rivals sprang up, vying to fill the void left by the widely resented intruders from North Africa. Among these rebellious Andalusians, the most successful was Muhammad ibn Yusuf ibn Nasr, a grandee who prided himself on is old Andalusian blood-line . . . The deal struck by the two, somewhere in the vicinity of Granada early in 1236, was relatively simple: Ferdinand would leave the lovely mountain-ringed city of Granada to Ibn Ahmar and his people, and Ibn Ahmar would help Ferdinand take the city the Christian really coveted, the one on the banks of the Gusdalquivir, Cordoba. Thanks chiefly to Ferdinand's protection, Ibn Ahmar was able to ensconce himself and, as it turned out, 250 years' worth of his descendants, in the relative seclusion and safety of the Sierra Nevada, in one of the Shangri-las of the West, Granada. Around this city, once known as 'Granada of the Jews,' was thus crafted the last Islamic kingdom of the European Middle Ages."