Learn about this topic in these articles:

Afghani history

The Treaty of Gandamak (Gandomak; May 26, 1879) recognized
Yaʿqūb Khan as emir, and he subsequently agreed to receive a permanent British embassy at Kabul. In addition, he agreed to conduct his foreign relations with other states in accordance “with the wishes and advice” of the British government. This British triumph, however, was short-lived. On September 3, 1879, the...

...and country, dying in exile early in 1879. The British army occupied Kabul, as it had in the first war, and a treaty signed at Gandamak on May 26, 1879, was concluded with the former emir’s son,
Yaʿqūb Khan.
Yaʿqūb Khan promised, in exchange for British support and protection, to admit to his Kabul court a British resident who would direct Afghan foreign relations, but...

Anglo-Afghan Wars

...dying in exile early in 1879. The British army occupied Kabul, as it had in the first war, and a treaty signed at Gandamak (Gandomak) on May 26, 1879, recognized Shīr ʿAlī’s son,
Yaʿqūb Khan, as emir. He subsequently agreed to receive a permanent British embassy at Kabul. In addition, he agreed to conduct his foreign relations with other states in accordance...