The 1842 retreat from Kabul (or Massacre of Elphinstone's army) took place during the First Anglo-Afghan War. At the beginning of the conflict, British and East India Company forces had defeated the forces of Afghan Emir Dost Mohammad Barakzai and in 1839 occupied Kabul, restoring the former ruler, Shah Shujah Durrani, as emir. However a deteriorating situation made their position more and more precarious, until an uprising in Kabul forced the then commander, Major General Sir William Elphinstone, to withdraw the garrison.