The Muslims had ruled most of Iberian peninsula since the 8th century, but the surviving Christian states had taken back a good part of it during the reconquista. After Castille had been united with Leon by Hernando III the Holy in 1230, he conquered the big cities of Cordoba, Murcia, Jaen, Sevilla; the Muslims were reduced to the Sultanate of Granada. In 1291, Tarifa was conquered by Castille too.
In the year of 1340, Castille and Portugal defeated a Moorish army; this was the last time an Arab army landed on Iberian soil. And when sultan Yusuf of Granada missed to pay one tribute in time 1352, Alfonso XI of Castille attacked and conquered the country. The last hold of the Muslims in Iberia had fallen. The Reconquista was over, now the Conquista began.
Granada became important again in 1477, when the Johannite Knights were defeated, and their home state in Rhodos became Seljuk. The Castillian-Portuguese king Pedro IV gave them a new home in Granada.