According to the Shahnameh (Book of Kings), by the Persian epic poet Ferdowsi, Afrasiab was the king and hero of Turan and an archenemy of Iran. In Iranian mythology, Afrasiab is considered by far the most prominent of all Turanian kings; he is a formidable warrior, a skilful general, and an agent of Ahriman, who is endowed with magical powers of deception to destroy Iranian civilization.
According to Middle Persian and Islamic sources, Afrasiab was a descendant of Tūr (Avestan: Tūriya-), one of the three sons of the Iranian mythical King Fereydun (the other two sons being Salm and Iraj). In Bundahishn he is named as the seventh grandson of Tūr. In Avestan traditions, his common epithet mairya- (deceitful, villainous) can be interpreted as meaning 'an evil man'. He lived in a subterranean fortress made of metal, called Hanakana.
According to Avestan sources, Afrasiab was killed by Haoma near the Čīčhast (possibly either referring to Lake Hamun in Sistan or some unknown lake in today's Central Asia), and according to Shahnameh he met his death in a cave known as the Hang-e Afrasiab, or the dying place of Afrasiab, on a mountaintop in Azerbaijan. The fugitive Afrasiab, having been repeatedly defeated by the armies of his adversary, the mythical King of Iran Kay Khosrow (who happened to be his own grandson, through his daughter Farangis), wandered wretchedly and fearfully around, and eventually took refuge in this cave and died.In Turkic literature Main article: Alp Er Tunga
Although the identification of the Turanian tribe with the Turks is a late development, since the term Turanian originally applied to Eastern Iranian tribes of Central Asia, Turks cultivated the legends of Afrasiab as a Turkish hero after they had come into contact with the Iranians. Mahmud al-Kashgari quotes in his Dīwān loḡāt al-Tork (5th/11th century) a number of elegiac verses lamenting the death of Alp Er Tunga