The city was founded by early Ibero-Celts whom traded with the Phoenicians and Carthaginians. The Greeks established a colony in the 5th century BC but were surplanted first by the Romans and then the Visigoths. The Moors finally captured the city in AD 713. There were periods of unrest and possession oscillated between the native Iberians and the North African Muslim invaders with the being destroyed in 1010. In 1228 the Nasrid dynasty was established by Ibn al-Ahmar and as the Kingdom of Granada it became a vassal state to Castile in 1238. It achieved success as a trading bridge between the Christian north and Muslim Africa trading gold and supplying mercenary soldiers. The Nasrids completed the building of the palace and fortress complex in the middle of the fourteeth century.
After being besieged by the Castilian forces of Ferdinand and Isabella, the the last Muslim leader, Muhammad XII surrendered the city on January 2, 1492. This marked the end of Muslim rule in the Iberian peninsula.