Shah Alam II (Ali Gohar), the seventeenth Mughal emperor, ascended the throne in a deteriorated Mughal Empire, with his power so diminished that it spawned the saying, "The empire of Shah Alam is from Delhi to Palam." His reign was plagued by invasions, notably by Ahmed Shah Abdali, leading to the pivotal Third Battle of Panipat in 1761 against the Marathas, who were then the de facto rulers of Delhi. In 1760, Shah Alam II was installed as the rightful emperor by the Marathas after they expelled Abdali's forces and deposed Shah Jahan III.
Shah Alam II's attempts to reclaim Mughal authority saw him engaging in various conflicts, including the Battle of Buxar in 1764 against the British East India Company, which resulted in his defeat and subsequent protection under the British through the Treaty of Allahabad. This treaty significantly reduced Mughal sovereignty by granting the Diwani of Bengal, Bihar, and Odisha to the British, marking a significant shift in power.
The Jat uprising against Mughal authority, fueled by Aurangzeb's religious intolerance, saw the Bharatpur Jat kingdom challenging Mughal dominion, including significant campaigns in territories like Agra. Suraj Mal, leading the Jats, notably seized Agra in 1761, plundering the city and even melting down the Taj Mahal's silver doors. His son, Jawahar Singh, expanded Jat control in Northern India, maintaining hold over strategic locations until 1774.
Simultaneously, Sikhs, aggrieved by Mughal oppression, notably the execution of Guru Teg Bahadur, intensified their resistance, culminating in the capture of Sirhind in 1764. This period of Sikh resurgence saw continuous raids into Mughal territories, further weakening Mughal hold over the region.
The Mughal Empire's decline was starkly evident under Shah Alam II, who witnessed the disintegration of Mughal power, culminating in Ghulam Qadir's betrayal. Qadir's brutal tenure, marked by the emperor's blinding and the humiliation of the royal family, ended with Mahadaji Shinde's intervention in 1788, restoring Shah Alam II but leaving the empire a shadow of its former self, largely confined to Delhi.
Despite these tribulations, Shah Alam II managed some semblance of sovereignty, notably during the 1783 Sikh siege of Delhi. The siege ended with an agreement facilitated by Mahadaji Shinde, granting the Sikhs certain rights and a portion of Delhi's revenue, showcasing the complex power dynamics of the time.
The final years of Shah Alam II's reign were under British oversight, following the Battle of Delhi in 1803. The once-mighty Mughal emperor, now a British protégé, witnessed the further erosion of Mughal influence until his death in 1806. Despite these challenges, Shah Alam II was a patron of the arts, contributing to Urdu literature and poetry under the pen name Aftab.