Ahmed Shah Abdali (also known as Ahmad Shah Durrani) invaded India multiple times between 1748-1767, most famously during the Third Battle of Panipat in 1761. At that time, Shah Alam II was the Mughal emperor (reigned 1760-1806), though he had little real power due to the declining Mughal authority. The other options are incorrect: Bahadur Shah I ruled earlier (1707-1712), Bahadur Shah II was much later (1837-1857), and Shah Alam I was not a historical Mughal emperor.