The end of the Second Afghan War in 1880 marked the beginning of almost 40 years of good relations between Britain and Afghanistan under the leadership of Abdur Rahman Khan and Habibullah Khan, during which time the British attempted to manage Afghan foreign policy through the payment of a large subsidy.
The death of Emir Abdur Rahman Khan in 1901 indirectly led to the war that began 18 years later. His successor, Habibullah, was a pragmatic leader who sided with Britain or Russia, depending on Afghan interests.
Afghanistan remained neutral during the First World War (1914–18), resisting considerable pressure from the Ottoman Empire.
Despite remaining neutral in the conflict, Habibullah did in fact accept a Turkish-German mission in Kabul and military assistance from the Central Powers.
When Habibullah was assassinated on February 20, 1919, by persons associated with the anti-British movement, his son Amanullah Khan took possession of the throne. At that time Britain still exercised an important influence on Afghan affairs.
In his coronation address Amanullah declared total independence from Great Britain. With sensing advantage in the rising civil unrest in India following the Amritsar massacre, Amanullah decided to invade British India.
The conflict began on 3 May 1919 when Afghan troops crossed the frontier at the western end of the Khyber Pass and captured the town of Bagh.
In response to this the British Indian government declared war upon Afghanistan on 6 May which lasted for more than a month.
The war resulted in the Afghans winning back control of foreign affairs from Britain, and the British recognizing Afghanistan as an independent nation.
The British also made some political gains, most notably the reaffirmation of the Durand Line – which had long been a contentious issue between the two nations – as a border separating Afghanistan from the North-West Frontier, and the undertaking that the Afghans made to stop interference on the British side of the line.
A peace treaty recognizing the independence of Afghanistan was signed at Rawalpindi on August 8, 1919, and was amended in 1921.