Few references to Lahore remain from before its capture by Sultan Mahmud of Ghazni in the eleventh century. The sultan took Lahore after a long siege and battle in which the city was torched and depopulated. In 1021, Sultan Mahmud appointed Malik Ayaz to the throne and made Lahore the capital of the Ghaznavid Empire of India. As the first Muslim governor of Lahore, Ayaz rebuilt and repopulated the city. He added many important features, such as city gates and a masonry fort, built in 1037–1040 on the ruins of the previous one, which had been demolished in the fighting (as recorded by Munshi Sujan Rae Bhandari, author of the Khulasatut Tawarikh in 1695–96). The present Lahore Fort stands on the same location. Under Ayaz's rule, the city became a cultural and academic center, renowned for poetry. The tomb of Malik Ayaz can still be seen in the Rang Mahal commercial area of town.
After the fall of the Ghaznavid Empire, Lahore was ruled by various Turk dynasties known as the Delhi Sultanate, including the Khiljis,Tughlaqs, Sayyid, Lodhis and Suris. When Sultan Qutb-ud-din Aibak was crowned here in 1206, he became the first Muslim sultan in South Asia. It was not until 1524 that Lahore became part of India's Mughal Empire. During the reign of Qutbuddin Aibak, Lahore was known as the 'Ghazni of India'. Scholars and poets from as far away as Kashghar, Bukhara, Samarkand, Iraq, Khorasan and Herat, gathered in Lahore and made it a city of learning. Under Aibak, Lahore had more poets of Persia than any other Islamic city. In the 13th Century, the Loharana king, Chahir Ray, was betrayed by his confidant Kualnger, who turned traitor for a large fortune in gold and gems. Due to this, the Lohana community split, and a new leader emerged who again unified the Lohanas. Veer Jashraj, who is revered as Veer Dada Jashraj, was born in the city of Lohar (today's Lahore in Pakistan), which was the capital of Lohargadh. His domain extended from Lahore to Multan (also in Pakistan today). As the folklore goes, Mongol invader Changez Khan, attacked Multan and was killed by Dada Jashraj, Rana of Lohargadh.
This finds mention in Mongol folklore, which say, "King of Mongols was killed by Mirana, the tiger of Multan fort". His descendants who proudly carry the surname of 'Mirana' preserve the memory of this great warrior king. Dada Jashraj was also treacherously killed when only 28 - a life so short but full of heroic deeds.
After the death of Dada Jashraj, the decline of Lohana kingdom began and their reign at Lohargadh ended. King Dahir ruled for a while from Narayankot (today's Hyderabad, Sindh).
After his demise in a war against Muslims, Narayankot and Sindh fell to Muslims. It was around this time that some Lohanas converted to Islam. Many migrated to far-off southern regions like Kutchchh, Saurashtra and Gujarat and gradually became a trader community like Agarwals and Baranwals.