Emperor Nadir Shah, the Shah of Iran (1736–47) and founder of the Afsharid dynasty, invaded Northern India with a fifty-five thousand strong army, eventually attacking Delhi in March 1739 where he sacked the city, after issuing orders for a general massacre to take place. His army had defeated the Mughal emperor Muhammad Shah at the battle at Karnal and had taken over control of northern India.
Nadir Shah became the ruler of Iran in 1736, his troops captured Esfahan from the Safavid dynasty and founded the Afsharid dynasty in that year. In 1738, Nadir Shah conquered Kandahar, the last outpost of the Hotaki dynasty, he, then, began to launch raids across the Hindu Kush mountains into Northern India, which, at that time, was under the rule of the Mughal Empire.
The Mughal empire had been weakened by ruinous wars of succession in the three decades following the death of Aurangzeb. The Muslim nobles had asserted their independence whilst the Hindu Marathas had caprtured vast swathes of territory in Central and Northern India. Its ruler, Muhammad Shah, proved unable to stop the disintegration of the empire. The imperial court administration was corrupt and weak whereas the country was extremely rich whilst Delhi’s prosperity and prestige was still at a high. Nadir Shah, attracted by the country's wealth, sought plunder like so many other foreign invaders before him.
Nadir had asked Muhammad Shah to close the Mughal frontiers around Kabul so that the Afghan rebels he was fighting against, may not seek refuge in Kabul. Even though the Emperor agreed, he practically took no action. Nadir seized upon this as a pretext for war. He defeated his Afghan enemies fleeing into the Hindu Kush and also seized major cities such as Ghazni, Kabul and Peshawar before advancing onto the Punjab and capturing Lahore. Nadir advanced to the river Indus before the end of year as the Mughals mustered their army against him.
At the Battle of Karnal on 13 February 1739, Nadir led his army to victory over the Mughals, Muhammad Shah surrendered and both entered Delhi together. The keys to the capital of Delhi were surrendered to Nadir. He entered the city on 20 March 1739 and occupied Shah Jehan’s imperial suite in the Red Fort. Coins were struck, and prayers said, in his name in the Jama Masjid and other Delhi mosques. The next day, the Shah held a great durbar in the capital.