Afzal al-Dīn Badīl ibn ʿAlī ibn ʿOthmān, commonly known as Khāqānī (, , – 1199), was a major Persian poet and prose-writer. He was born in Transcaucasia in the historical region known as Shirvan, where he served as an ode-writer to the Shirvanshahs. His fame most securely rests upon the qasidas collected in his Divān, and his autobiographical travelogue Tohfat al-ʿErāqayn. He is also notable for his exploration of the genre that later became known as habsiyāt ("prison poetry"). Life Khaqani was born into the family of a carpenter in Shirvan. Khaqani's mother was originally a slave-girl of Nestorian Christian faith who had converted to Islam. According to Khaqani, she was a descendant of "the great Philippus", which some scholars such as Minorsky (1945) have interpreted as meaning Marcus Julius Philippus. Khaqani lost his father at an early age and was brought up by his uncle, Kāfi-al-Din ʿOmar, a physician. Later in life, Khaqani wrote a poem in his praise, in which he used the similarity of his uncle's name and that of Omar Khayyam to compare their virtues. Khaqani may have been a child prodigy, since several of his poems can be dated to his early youth, indicating that he had become the eulogist of Manuchihr III at an early age. In his early youth, Khaqani wrote under the pen name Haqaiʿqi ("Seeker"). The Shirvanshahs bore the title Khaqan, from which he later derived the pen name, Khaqani ("regal"). Some traditional stories describe him as being the pupil and son-in-law of the famed poet Abul-Ala Ganjavi, however, this is not corroborated by Khaqani's own writings. Khaqani in his youth decided to embark on a pilgrimage to Mecca, against the wishes of his ruler and patron. In his first attempt to depart Shirvan, he was captured by Manuchihr's henchmen in the nearby Beylagan. Charged with being insubordinate, he was imprisoned for a period of 5 or 7 months in an ancient fortress in Shabaran, near Darband. Khaqani was condemned to a number of subsequent imprisonments, until in 1156-7 he succeeded in escaping and setting out on a lengthy expedition through the Middle East. His travels gave him material for his famous work Tohfat al-ʿErāqayn (A Gift from the Two Iraqs; in reference to western Iran ('Persian Iraq') and Mesopotamia ('Arabic Iraq'). He also composed his famous qasida The Portals at Madāʾen, in which the contemplation of Taq-i Kisra (the ruins