

Dost Mohammad established the Barakzay (or Mohammadzai) dynasty. His position secure after he assumed the title of amir in 1826 at Kabul, he decided to recover Peshawar from the Sikhs. Declaring a jihad, or Islamic holy war, in 1836, he advanced on Peshawar. The Sikh leader Ranjit Singh, however, sowed dissension in Dost Mohammad's camp, the invading army melted away, and Peshawar was permanently lost to the Afghans.
In November 1837 Mohammad Shah of Persia laid siege to Herat, which the British saw as the key to India. The Russians supported the Persians. The British, fearful that Persia was falling completely under Russian influence, entered into alliances with the rulers of Herat, Kabul, and Qandahar. A British mission to Kabul under Captain (later Sir) Alexander Burnes in 1837 was welcomed by Dost Mohammad, who hoped the British would help him recover Peshawar. Burnes could not give him the required assurances; and when a Russian agent appeared in Kabul, the British left for India.
With the failure of Burnes's mission, the governor general of India, Lord Auckland, ordered an invasion of Afghanistan, with the object of restoring Shah Shoja' to the throne. In April 1839, after suffering great privations, the British Army entered Qandahar; Shah Shoja' was then crowned shah. Ghazna was captured in the following July, and in August Shah Shoja' was installed at Kabul. Dost Mohammad escaped first to Balkh, then to Bukhara, where he was arrested. The Afghans, however, would tolerate neither a foreign occupation nor a king imposed on them by a foreign power, and insurrections broke out. Dost Mohammad escaped from prison and returned to Afghanistan to lead his partisans against the British. In a battle at Parwan on Nov. 2, 1840, Dost Mohammad had the upper hand, but the next day he surrendered to the British in Kabul. He was deported to India with the greater part of his family.
Outbreaks continued throughout the country, and the British eventually found their position untenable. Terms for their withdrawal were discussed with Akbar Khan, Dost Mohammad's son, but Sir William Hay Macnaghten, the British political agent, was killed during a parlay with the Afghans. On Jan. 6, 1842, some 4,500 British and Indian troops, with 12,000 camp followers, marched out of Kabul. Bands of Afghans swarmed around them, and the retreat ended in a blood bath. Shah Shoja' was killed after the British left Kabul.
Though in the summer of the same year British forces reoccupied Kabul, the new governor general, Lord Ellenborough, decided on the evacuation of Afghanistan. In 1843 Dost Mohammad returned to Kabul. During the next 20 years Dost Mohammad consolidated his rule by occupying Qandahar (1855), Balkh and the northern Khanates (1859), and Herat (1863), the last less than a month before his death in June 1863.