Knowing the local history is a good incentive to better appreciate what to see in Iznájar. Thus, the place name comes from the Arabic words hisn (castle) and ashar (joyful). It is believed, however, that it was occupied for many centuries before by Iberians and Romans. An old Romancero gives the name of Angellas to the town and associates it with the Roman period.
From 742 it became part of the Cora de Rayya, whose capital was in Archidona. Towards the end of the 9th century the area came under the control of the rebel Omar Ben Hafsun, a muladi who for several decades successfully fought the Caliphate of Córdoba. Thus, during 886 Iznájar was besieged by the troops of the Emir of Córdoba Al-Mundir. He did not hesitate to be cruel and he went on to murder the majority of the population.
The continuous and bloody reprisals greatly frightened the local inhabitants. Because of this, in the year 911 and to avoid further reprisals, they murdered the rebel leader. The head of the muladi Fadl ben Salama was sent to the emir of Córdoba as a sign of submission. As a reward for his later loyalty, Abderraman III rebuilt the castle. Thus, it became practically impregnable due to the steepness of the hill that houses it.
When Almanzor died and the Caliphate of Córdoba broke down, the Berber leader Habus Ben Maksan conquered Iznájar. Thanks to this he acted as head of Taifa until 1019. Then, Granada replaced it as the capital. From then on, the fortress acted as an advanced defense against the Castilians.
During 1341, Alfonso XI arrived to its walls. However, bad weather prevented the consequent siege from taking place. Twenty years later Pedro I, helped by the deposed Muhamed V of Granada, took Iznájar. However, when the Nasrid monarch recovered his kingdom he did the same with this town in Córdoba.
The final takeover occurred on 4 December 1431. John II was responsible for making it pass for the last time into Castilian hands. During 1468 it entered the jurisdiction of Juan Fernández de Córdoba, Lord of Baena and Count of Cabra. In this way he also became Viscount of Iznájar.
On June 28, 1861, a group of 600 day laborers led by Rafael Pérez del Álamo assaulted the Guardia Civil barracks. The slogan they shouted was “Long live freedom and death to the queen”. On the next day, after gathering some ten thousand troops, they sacked Loja. The rebellion lasted a week, until the army troops arrived.