The Shaikh Najm ad-Dīn Abū Ḥafṣ ‘Umar ibn Muḥammad an-Nasafī, who was a teacher of spirits and men, had related a legend about the founding of Samarkand that the city was founded by Iskandar Dhu al-Qarnayn¹ and he placed Samar and Kamer at the head of the construction who completed it. The story goes that Samar, liking this water and air, first dug a well from which he took out the earth, and then ordered that well to be filled with earth. As much urine as they had, they tamped into the earth of the well, but there was a surplus. The surplus earth from this well was used for the foundation of the city. They said that grace descended on the well, for if the earth from the well were less, the city would not have been built, for the scholars have written in the books of tradition that if anyone wants to build a structure or plant a tree, he should dig a hole, take out the earth and then fill it up again, and if the earth turns out to be too much, then that place is considered happy, but if the earth turns out to be too little, then one should abstain: no matter how hard the work, the work is in vain and the work will not last. They say that where Samarkand lies there used to be a mountain of earth containing grains of gold, and now if you find pieces of that earth and hold them up to the sun, they naturally shine with gold.
¹Dhu al-Qarnayn, (Arabic: ذُو ٱلْقَرْنَيْن Ḏū al-Qarnayn, IPA: [ðuː‿l.qar.najn], lit.: “He of the Two Horns”), also spelled Zu al-Qarnayn, appears in the Quran, Surah Al-Kahf (18), Ayahs 83–101 as one who travels to east and west and erects a wall between a certain people and Gog and Magog (called Ya’juj and Ma’juj). Elsewhere the Quran tells how the end of the world would be signaled by the release of Gog and Magog from behind the wall, and other apocalyptic writings report their destruction by God in a single night would usher in the Day of Resurrection (Yawm al-Qiyāmah).
Early Muslim commentators and historians assimilated Dhu al-Qarnayn to several figures, among them Alexander the Great, Parthian king Kisrounis, the South-Arabian Himyarite king Sa’b Dhu Marathid, and the North-Arabian Lakhmid king al-Mundhir ibn Imru al-Qays. Some have argued that the origins of the Quranic story lies in the Syriac Alexander Legend, but others disagree citing dating inconsistencies and missing key elements. Some modern Muslim scholars are in favor of identifying him with Cyrus the Great.