The Gandomak Treaty is an agreement between Amir Muhammad Yaqub of Afghanistan and Major Pierre Louis Napoleon Cavagnari, representing the British Government of India, signed at the British army camp near the village of Gandomak, about seventy miles east of Kabul, on 26 May 1879, and ratified by Lord Edward Robert Bulwer Lytton, Viceroy of India, on 30 May 1870. Most historical writings consider the Treaty of Gandomak as the prelude to the Second Anglo-Afghan War, 1879-1880.
On 22 July 1878 a Russian delegation arrived in Kabul without the explicit invitation of Ameer Sher Ali Khan. To counteract the Russian initiative the British, in early August 1878, informed the Amir that he must receive a British mission that included European members "with all becoming honors" (Singhal, p. 35). The mission was denied entry into Afghanistan at the Afghan military post of Ali Masjid in the Khyber pass on September 21st. In retaliation, the British Government of India issued an ultimatum that by 20 November 1878 the Amir must apologize and provide a satisfactory explanation for the "insult." Sher Ali's response of 19 November 1878, delayed by the death of his son and heir apparent on August 17th, did not reach the Viceroy until November 30th, and lacked an apology (Singhal, p. 39). On November 21st the British declared war on Afghanistan, occupied the Korram valley and the Paywar pass, and moved its armed forces via the Khaybar pass and Quetta towards Jalalabad and Qandahar, respectively. Unable to offer effective military resistance, on 23 December 1878, the Amir left Kabul for Turkestan, intending to seek Russian aid for the defense of his domains. Sher Ali died on 21 February 1879 near Balkh and his son, Muhammad Yaqub, declared himself Amir of Afghanistan. On 26 May 1879, after preliminary correspondence with Cavagnari and prior to the British withdrawal from most occupied Afghan territories, Muhammad Yaqub's request for permission to visit the British military camp was accepted, and so he proceeded there to sign the Treaty of Gandomak, "the most humiliating ever signed by an Afghan ruler" (Kakar, p. 12), making the Afghan Amir "virtually a feudatory of the British Crown" (Singhal, p. 45).
Under the provisions of the treaty the Amir surrendered control to the British over the foreign relations of Afghanistan and allowed for a British Mission, with European members, to reside in Kabul. Jurisdiction over the Korram and Pishin valleys, the Sibi district, and the Khaybar pass was transferred to the British. The treaty provided for increased commercial contacts and the establishment of a telegraph line between Kabul and British India. Muhammad Yaqub was to receive an annual subsidy of 600,000 rupees and to issue amnesty to all those who had collaborated with the British occupying forces. The British Mission led by Cavagnari arrived in Kabul on 24 July 1879. On 3 September 1879, a dissatisfied regiment of the Amir's army from Herat stormed the mission compound and massacred all its members, including Cavagnari. The event set the stage for another British invasion of Afghanistan, the expulsion of Muhammad Yaqub to India, and the Second Anglo-Afghan War, which culminated in the British appointment of Abdur RAhman (ruled 22 July 1880 - 1 October 1901), patrilateral parallel cousin of Yaqub, as Amir of Afghanistan. Abdur Rahman accepted, in principle, the provisions of the Treaty of Gandomak with the modification that the British agent and his staff in Kabul would be Indian Muslims.