The Mughal Emperor Shah Alam II (1759–1806) made futile attempts to reverse the Mughal decline but ultimately had to seek the protection of the Emir of Afghanistan, Ahmed Shah Abdali, which led to the Third Battle of Panipat between the Maratha Empire and the Afghans (led by Abdali) in 1761. In 1771, the Marathas recaptured Delhi from Afghan control and in 1784 they officially became the protectors of the emperor in Delhi, a state of affairs that continued until the Second Anglo-Maratha War. Thereafter, the British East India Company became the protectors of the Mughal dynasty in Delhi. The British East India Company took control of the former Mughal province of Bengal-Bihar in 1793 after it abolished local rule (Nizamat) that lasted until 1858, marking the beginning of British colonial era over the Indian Subcontinent. By 1857 a considerable part of former Mughal India was under the East India Company's control. After a crushing defeat in the war of 1857–1858 which he nominally led, the last Mughal, Bahadur Shah Zafar, was deposed by the British East India Company and exiled in 1858. Through the Government of India Act 1858 the British Crown assumed direct control of East India Company-held territories in India in the form of the new British Raj. In 1876 the British Queen Victoria assumed the title of Empress of India.