The top of the rock in Afyon has been fortified for a long time. It was known to the Hittites as Hapanuwa, and was later occupied by Phrygians, Lydians and Achaemenid Persians until it was conquered by Alexander the Great. After the death of Alexander the city (now known as Akroinοn (Ακροϊνόν) or Nikopolis (Νικόπολις) in Ancient Greek), was ruled by the Seleucids and the kings of Pergamon, then Rome and Byzantium. The Byzantine emperor Leo III after his victory over Arab besiegers in 740 renamed the city Nicopolis (Greek for "city of victory"). The Seljuq Turks then arrived in 1071 and changed its name to Kara Hissar ("black castle") after the ancient fortress situated upon a volcanic rock 201 meters above the town. Following the dispersal of the Seljuqs the town was occupied by the Sâhib Ata and then the Germiyanids. The castle was much fought over during the Crusades and was finally conquered by the Ottoman Sultan Beyazid I in 1392 but was lost after the invasion of Timur Lenk in 1402. It was recaptured in 1428 or 1429.
The area thrived during the Ottoman Empire, as the centre of opium production and Afyon became a wealthy city with the typical Ottoman urban mixture of Turks and Armenians. During the 1st World War British prisoners of war who had been captured at Gallipoli were housed here in an empty Armenian church at the foot of the rock. During the Greco-Turkish War (1919-1922) campaign (part of the Turkish War of Independence), Afyon and the surrounding hills were occupied by French, Italian and then Greek forces. However, it was recovered on 27 August 1922, a key moment in the Turkish counter-attack in the Aegean region. After 1923, Afyon became a part of the Republic of Turkey.
The region was a major producer of raw opium (hence the name Afyon) until the late 1960s when under international pressure, from the USA in particular, the fields were burnt and production ceased. Now poppies are grown under a strict licensing regime. They do not produce raw opium anymore but derive Morphine and other opiates using the poppy straw method of extraction.