Early Muslim period in Lahore
The early Muslim period refers to the start of Muslim rule in the history of Lahore. In 664/682, the city was besieged by Muslim forces led by Muhallab ibn Abi Sufra. 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. 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 Muslim dynasties known as the Delhi Sultanate, including the Khaljis, 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. Fall of the sultanate

The last Lodi ruler, Ibrahim Lodi was greatly disliked by his court and subjects. Upon the death of his father Sikander Lodi, he quashed a brief rebellion led by some of his nobles who wanted his younger brother Jalal Khan to be the Sultan. After seizing the throne by having Jalal Khan murdered, he never really did succeed in pacifying his nobles. Subsequently Daulat Khan, the governor of Punjab and Alam Khan, his uncle, sent an invitation to Babur, the ruler of Kabul to invade Delhi. In 1241, the ancient city of Lahore was conquered by the Mongols, the entire population of the city was massacred and the city was leveled to the ground. There are no buildings or monuments in Lahore that predates Mongol destruction. The new Mughal dynasty was to rule India for another 300 years. The first Battle of Panipat (April 1526) was fought between the forces of Babur and the Delhi Sultanate. Ibrahim Lodi was killed on the battlefield. By way of superior generalship, vast experience in warfare, effective strategy, and appropriate use of artillery, Babur won the First battle of Panipat and subsequently occupied Agra and Delhi. The new Mughal dynasty was to rule India for another 300 years. 