In 1874 a new government in London, led by Benjamin Disraeli (1804–1881), adopted a more aggressive stance in India and appointed a strong-minded governor general. In an atmosphere of growing tension, a Russian delegation, apparently uninvited, visited Kabul in July 1878. The British issued an ultimatum asking for equal rights of access to Kabul. When this ultimatum was rejected, the British crossed the border and thereby started the Second Anglo-Afghan War (1878–1879).
The Afghans were quickly defeated, and the war was concluded with the Treaty of Gandamak (May 29, 1879). The treaty included the stipulation that Afghanistan would remain an independent nation, but would conduct its foreign policy via the British rulers in India in lieu of regular subsidies and a British guarantee regarding the security of the country.
In the summer of 1879 a British embassy under Major Pierre Louis Cavagnari (1841–1879) was sent to Kabul, but shortly afterwards (September 1879), it was wiped out by an angry Afghan mob. The British felt compelled to occupy Kabul, but again realized that a permanent occupation of the country was too costly. British troops eventually withdrew from Afghanistan in 1881, leaving behind a young and ruthless ruler, Abdur Rakhman Khan (ca. 1844–1901). Under the protection of the British and under the stipulations of the Treaty of Gandamak, Abdur Rakhman Khan quickly modernized the country and built up central authority.
Source Citation (MLA 7th Edition)
Vogelsang, Willem. “Afghan Wars.” Encyclopedia of Western Colonialism since 1450. Ed. Thomas Benjamin. Vol. 1. Detroit: Macmillan Reference USA, 2007. 14-17. U.S. History In Context. Web. 20 May 2016.