After Muhammad Shah's death in 1748, bitter struggles, and even civil war broke out among unscrupulous and power hungry nobles. Furthermore, as a result of the weakening of the north-western defenses, the Empire was devastated by the repeated invasions of Ahmed Shah Abdali, one of Nadir Shah's ablest generals, who had succeeded in establishing his authority over Afghanistan after his master's death.
Abdali repeatedly invaded and plundered northern India right down to Delhi and Mathura between 1748 and 1767.
In 1761, Abdali defeated the Maratha in the Third Battle of Panipat and thus gave a big blow to their ambition of controlling the Mughal Emperor and thereby dominating the country.
After defeating Mughal and Maratha, Abdali did not, however, found a new Afghan kingdom in India. He and his successors could not even retain the Punjab which they soon lost to the Sikh chiefs.
As a result of the invasions of Nadir Shah Abdali and the suicidal internal feuds of the Mughal nobility, the Mughal Empire had (by 1761) ceased to exist in practice as an all-India Empire.
Mughal Empire narrowed merely as the Kingdom of Delhi. Delhi itself was a scene of 'daily riot and tumult'.
Shah Alam II, who ascended the throne in 1759, spent the initial years as an Emperor wandering from place to place far away from his capital, for he lived in mortal fear of his own war.
Shah Alam II was a man of some ability and ample courage. But the Empire was by now beyond redemption.
In 1764, Shah Alam II joined Mir Qasim of Bengal and Shuja-ud-Daula of Avadh in declaring war upon the English East India Company.
Defeated by the British at the Battle of Buxar (October 1764), Shah Alam II lived for several years at Allahabad as a pensioner of the East India Company.
Shah Alam II left the British shelter in 1772 and returned to Delhi under the protective arm of the Marathas.
The British occupied Delhi in 1803 and since that time to till 1857, when the Mughal dynasty was finally extinguished, the Mughal Emperors merely served as a political front for the English.