Lahore was taken by the Marathas in 1758 and by the Sikhs in 1799.
Panipat District Gazetteer, a geographical map about Haryana's history, states that the Marathas controlled a large portion of central and northern India. The Marathas occupied Lahore in 1758, driving out Timor Shah Durrani, the Afghan ruler's son. Their empire extended from the Indus to the Himalayas and nearly to the peninsula's tip in the south. However, the Mughals retained the formal authority of Delhi, who were disturbed by the changes. This invitation planted the seeds for a fierce conflict in the region on January 14, 1761, known as the Third Battle of Panipat.
According to the Maharashtra government, the Marathas were defeated at Panipat in 1761, and Pesava Balaji, who never recovered from that devastating blow, died on June 23, 1761. The region was taken over by Afghanistan's monarch, Ahmad Sah Abdali.
According to the Punjab (Pakistan) government portal, Lahore was ruled by Maharaja Ranjit Singh, the Sikh ruler of Punjab, in 1799. In all of the areas between British India and the Durrani Empire, Ranjit built a unified Sikh monarchy.
According to the Parliament Digital Library, Ranjit Singh intended to conquer Lahore because it was a strategically vital town. He attended private meetings with the town's Hindu and Muslim residents. He ordered a nocturnal assault on Lahore, which was led by his mother-in-law Rani Sada Kaur.