Siege of Lahore (1186)
The Siege of Lahore in 1186 brought the end of Ghaznavid rule with Muhammad of Ghor annexing their last-surviving principality from Khusrau Malik. Across the 1180s, Muhammad had made at least three incursions into the Ghaznavid domain centered around Punjab. The first attempt resulted in a truce and the second — despite the plunder of Lahore and gaining of Sialkot — turned out to be unsuccessful before his third attempt secured victory, likely employing deceit. Both the reigning Ghaznavid Sultan and the prince were imprisoned and executed. Background
The Ghurids — warlords or chieftains based out of Ghur but of uncertain ancestry — originally served as nominal vassals to both the Seljuks and Ghaznavids since c. early eleventh century. Early Ghurid history remains unclear but one Sayf al-Din Suri had conquered Ghazni, the Ghaznavid capital, in 1148 only to lose it a year later. Three years later, Suri's brother sacked and retook Ghazni, forcing Baharam Shah to flee east; while Ghazni wwould be won back — probably due to a rebellious populace —, the contemporaneous advent of Oghuz Turks ensured a permanent cessation of their western frontiers including the capital. By 1160s, the Ghaznavids held no sway over Central Asian lands and their new territory became centered around Punjab, probably spanning till the valley of Kabul, with the new capital at Lahore. Contemporaneous with the rapid plummet of Ghaznavids, the Ghurids reached zenith under the dyarchy of Ghiyath al-Din Mahmud and Muhammad of Ghor; Muhammad had Ghazni annexed from the Turks and soon, most of the eastern Afghanistan fell under Ghurid control. Thereafter, Muhammad focused on mainland India and in 1178, marched down through the Gomal Pass — via Multan and Uch — to enter into Gujarat via the Thar only to end up routed by an alliance of Rajput chiefs under Mularaja II. The defeat did not dampen Muhammad's aspirations and spurred the search for an alternate non-tortuous passage into the mainland — via Lahore — leading him into multiple conflicts with the Ghaznavids. Sources 
As the Ghaznavid polity shifted eastward from the Islamic heartland, it became insignificant for Muslim historians. Barring Ibn al-Athir's al-Kāmil fit-Tārīkh, we have no contemporary description of the fall of Ghaznavids; however, al-Athir's description of the eastern frontiers were derived from local historians and ridden with self-acknowledged inconsistencies in dates. The next extant source — recorded about a century after the event — remains Minhaj-i Siraj Juzjani's Tabaqat-i Nasiri, which is largely understood to be the official history of the succeeding Mamluk dynasty. The events are also described in the 16th century Tarikh-i Firishta by Firishta, probably deriving from non-extant sources. The only description of the siege and relevant circumstances from a non-Muslim perspective comes from Rajdarshani, a history of Jammu Rajahs compiled at the orders of Gulab Singh c. 1847 by Gopal Das, some 700 years after the event. The accuracy of the work remains suspect with Das primarily depending on vamsavalis and bardic lore as his sources; it is probable that Das tried to increase the prestige of the Rajahs by associating them with a pre-eminent dynasty of yore. Ghurid Attacks

First raid
al-Athir records that Muhammad launched multiple attempts to take over Lahore since he had gained Ghazna but Khusrau Malik's forces did not allow him to cross the Indus. In 1178, Muhammad annexed Peshawar from probably the Ghaznawids and two years later, besieged Lahore; this time, Malik — under parallel attacks from Indian Kings — negotiated for peace, pledging allegiance to the Ghurids and gifting his son Malik Shah along with a elephant to Muhammad, but preserving his territory. Second raid
In 580/581 H. (c. 1184-1186 C.E.) Muhammad sacked Lahore but failed to conquer it; nonetheless, he had Sialkot annexed before returning back to Ghazni. Muslim sources do not mention what caused the breach of peace between Muhammad and Malik; Das claims Chakradeva — then-ruler of Jammu — invited Muhammad since the Khokhars had refused allegiance to the Rajahs under Ghaznavid encouragement. Soon, Husain Kharmil, the Ghurid governor in charge of the new fortified encampment, had to repulse a joint maneuver by Malik and Khokhar tribesmen to recapture Sialkot. More importantly, this failure led the Khokhars to desert the Ghaznavids — on account of receiving no sack-spoils — and weakened Malik's power. Conquest 
Sources converge upon that Lahore was captured by Muhammad in 583 H. (1186-1187 C.E.) in a fresh siege thus bringing an end to the Ghaznavid rule of two centuries; the specifics — though widely inconsistent— involve deceit as a common motif. Jujzani records that Khusrau Malik, having understood the futility of resistance to a waxing Ghurid power, wished to negotiate peace with Muhammad and was promised a meeting outside the city; however, he was captured on leaving Lahore and incarcerated at Ghazni, before being taken away to Ghiyath al-Din in Firozkoh who had him shifted to a fortress in Gharchistan. al-Athir noted Khusrau Malik to have had successfully negotiated peace with Muhammad and ruled as a Ghurid vassal for a couple of months but then, Ghiyath al-Din solicited Malik and his son's appearance at his court at Firozkoh only to deny them an audience and have them imprisoned. Firishta provides a different narrative — Khusrau Malik was lulled into a false sense of security on Muhammad choosing to return back Malik Shah; little did he know about the Ghurid army's rapid advance towards Lahore and ended up deposed in a bloodless coup. Whatever be the specifics of the conquest, both Khusrau Malik and his son would be executed c. 1192 or thereabouts; it might have been to avoid them being used as bargaining chips by Ala al-Din Tekish. Legacy
With the possession of Punjab, Muhammad was able to leverage another easier route into North India and would go on to win the Second Battle of Tarain. By the turn of the century, he and his "slave sons" had overrun most of the Gangetic Plain expanding as far as Bengal. Das claims that Devas were conferred with the title of Mian and installed as a vassal for the Sialkot province, as a token of gratitude. Notes

References

Bibliography

 
 
 
 
 
 
 

Battles involving the Ghaznavid Empire
Battles involving the Ghurids
History of South Asia
History of Lahore
History of Islam in India
Islamic rule in the Indian subcontinent
1180 in Asia