thumb|Map of Afghanistan (Emirate) and surrounding nations, dated 1860. thumb|Map of Afghanistan 1839–1863, showing the First Anglo-Afghan war, and unification of Afghanistan by Dost Mohammad Khan thumb|King Yaqub Khan with Britain's Sir Pierre Louis Napoleon Cavagnari, 26 May 1879, on the occasion of the signing of the Treaty of Gandamak The Emir Dost Mohammad Khan (1793–1863) gained control in Kabul in 1826 after toppling his brother, Sultan Mohammad Khan, and founded () the Barakzai dynasty. In 1837, the Afghan army descended through the Khyber Pass on Sikh forces at Jamrud killed the Sikh general Hari Singh Nalwa but could not capture the fort.Nalwa, V. (2009), Hari Singh Nalwa – Champion of the Khalsaji, New Delhi: Manohar, p. 198, . Rivalry between the expanding British and Russian Empires in what became known as the "Great Game" significantly influenced Afghanistan during the 19th century. British concern over Russian advances in Central Asia and over Russia's growing influence in West Asia and in Persia in particular culminated in two Anglo-Afghan wars and in the Siege of Herat (1837–1838), in which the Persians, trying to retake Afghanistan and throw out the British, sent armies into the country and fought the British mostly around and in the city of Herat. The first Anglo-Afghan War (1839–1842) resulted in the destruction of a British army; causing great panic throughout British India and the dispatch of a second British invasion army.archive.org: "Sale's brigade in Afghanistan, with an account of the seizure and defence of Jellalabad", by Gleig, G. R. (George Robert), 1796–1888. London: John Murray, 1846 Following the British defeat in the First Anglo-Afghan War, where they tried to re-establish the Durrani Kingdom as a de facto vassal, Dost Mohammad could focus on reuniting Afghanistan, which was divided following the Durrani-Barakzai civil wars. Dost Mohammad began his conquest while only ruling the major cities of Kabul, Ghazni, Jalalabad, and Bamyan. By the time of his death in 1863, Dost Mohammad had reunited most of Afghanistan. Following Dost Mohammad's death, a civil war broke out amongst his sons, leading to Sher Ali succeeding and beginning his rule. The Second Anglo-Afghan War (1878–1880) resulted from the refusal by Emir Sher Ali (reigned 1863 to 1866 and from 1868 to 1879) to accept a British diplomatic mission in Kabul. In the wake of this conflict Shir Ali's nephew, Emir Abdur Rahman, known as the "Iron Emir", came to the Afghan throne. During his reign (1880–1901), the British and Russians officially established the boundaries of what would become modern Afghanistan. The British retained effective control over Kabul's foreign affairs. Abdur Rahman's reforms of the army, legal system and structure of government gave Afghanistan a degree of unity and stability which it had not before known. This, however, came at the cost of strong centralisation, of harsh punishments for crime and corruption, and of a certain degree of international isolation."Afghanistan and the Search for Unity " Omrani, Bijan, published in Asian Affairs, Volume 38, Issue 2, 2007, pp. 145–57.
thumb|Map of Afghanistan (Emirate) and surrounding nations, dated 1860. thumb|Map of Afghanistan 1839–1863 showing the First Anglo-Afghan war, and unification of Afghanistan by Dost Mohammad Khan thumb|King Yaqub Khan with Britain's Sir Pierre Louis Napoleon Cavagnari, 26 May 1879, on the occasion of the signing of the Treaty of Gandamak The Emir Dost Mohammad Khan (1793–1863) gained control in Kabul in 1826 after toppling his brother, Sultan Mohammad Khan, and founded () the Barakzai dynasty. In 1837, the Afghan army descended through the Khyber Pass on Sikh forces at Jamrud killed the Sikh general Hari Singh Nalwa but could not capture the fort.Nalwa, V. (2009), Hari Singh Nalwa – Champion of the Khalsaji, New Delhi: Manohar, p. 198, . Rivalry between the expanding British and Russian Empires in what became known as the "Great Game" significantly influenced Afghanistan during the 19th century. British concern over Russian advances in Central Asia and over Russia's growing influence in West Asia and in Persia in particular culminated in two Anglo-Afghan wars and in the Siege of Herat (1837–1838), in which the Persians, trying to retake Afghanistan and throw out the British, sent armies into the country and fought the British mostly around and in the city of Herat. The first Anglo-Afghan War (1839–1842) resulted in the destruction of a British army; causing great panic throughout British India and the dispatch of a second British invasion army.archive.org: "Sale's brigade in Afghanistan, with an account of the seizure and defence of Jellalabad", by Gleig, G. R. (George Robert), 1796–1888. London: John Murray, 1846 Following the British defeat in the First Anglo-Afghan War, where they tried to re-establish the Durrani Kingdom as a de facto vassal, Dost Mohammad could focus on reuniting Afghanistan, which was divided following the Durrani-Barakzai civil wars. Dost Mohammad began his conquest while only ruling the major cities of Kabul, Ghazni, Jalalabad, and Bamyan. By the time of his death in 1863, Dost Mohammad had reunited most of Afghanistan. Following Dost Mohammad's death, a civil war broke out amongst his sons, leading to Sher Ali succeeding and beginning his rule. The Second Anglo-Afghan War (1878–1880) resulted from the refusal by Emir Sher Ali (reigned 1863 to 1866 and from 1868 to 1879) to accept a British diplomatic mission in Kabul. In the wake of this conflict Shir Ali's nephew, Emir Abdur Rahman, known as the "Iron Emir", came to the Afghan throne. During his reign (1880–1901), the British and Russians officially established the boundaries of what would become modern Afghanistan The British retained effective control over Kabul's foreign affairs. Abdur Rahman's reforms of the army, legal system and structure of government gave Afghanistan a degree of unity and stability which it had not before known. This, however, came at the cost of strong centralisation, of harsh punishments for crime and corruption, and of a certain degree of international isolation."Afghanistan and the Search for Unity " Omrani, Bijan, published in Asian Affairs, Volume 38, Issue 2, 2007, pp. 145–57.