First traces of human presence in the area date to the middle
Palaeolithic Age. The
Romans captured it from the
Iberians during the time of the
Roman Republic and named it Ipagro, which took part in the civil war between
Julius Caesar and
Pompey, and flourished in the early
Imperial Age. After the fall of the
Western Roman Empire, it was ruled by the
Visigoths and, from the 8th century, by the Muslim
emirate of Córdoba, with the name of Bulay (also Pulay). In the 9th century it became the headquarters of the rebel
Umar ibn Hafsun, who built extensive fortifications and reinforced the castle. However, in 891, Umar ibn Hafsun lost the town to emir
Abdallah ibn Muhammad of Córdoba. Due to its strategic position, it was contested and, after the dissolution of the
caliphate of Córdoba, it became part of the
cora of
Cabra. In 1240 it was conquered by the Christians, although numerous Muslims were allowed to remain. King
Peter I of Castile assigned its seigniory to Alfonso Fernandez Coronel, but later reannexed it to the crown. The town was renamed
Aguilar of the Frontier due to its position on the border with the Moorish
Kingdom of Granada. In 1370, due to the loyalty shown in the civil war, King
Henry II of Castile gave Aguilar to Gonzalo Fernandez de Cordoba, first of a dynasty who held the town until the abolition of feudalism in the 19th century. The town grew until the 1570s-1580s, after which it decayed, also due to several
plague outbreaks which decimated the population, and to the shrinking level of the agriculture. During the
Spanish Civil War Aguilar sided with the Nationalist faction. Many of its citizens fell fighting for the nationalist cause. A cross erected in their honour was demolished in 2021 by the town hall, causing international outrage. == Ecclesiastical history ==