Mohammad Yaqub Khan (Pashto/Dari: ; 1849November 15, 1923) was Emir of Afghanistan from February 21 to October 12, 1879. He was the son of the previous ruler, Sher Ali Khan. Mohammad Yaqub Khan was appointed as the governor of Herat province in 1863. In 1870, he decided to rebel against his father but failed and was imprisoned in 1874. The Second Anglo-Afghan War erupted in 1878, leading Sher Ali Khan to flee the capital of Afghanistan, and eventually die in February 1879 in the north of the country. As Sher Ali's successor, Yaqub signed the Treaty of Gandamak with Britain in May 1879, relinquishing sole control of Afghanistan foreign affairs to the British Empire. An uprising against this agreement led by Ayub Khan in October of the same year, led to the abdication of Yaqub Khan. He was succeeded by the new ruler, Amir Ayub Khan. Treaty of Gandamak During the Second Anglo-Afghan War, the British defeated the Amir Sher Ali's forces, wintered in Jalalabad, waiting for the new Amir Yakub Khan to accept their terms and conditions. One of the key figures in the negotiations was Pierre Louis Napoleon Cavagnari, who served with the East India Army in the 1st Bengal Fusiliers and then transferred into political service, becoming Deputy Commissioner at Peshawar, and was appointed as envoy by the Viceroy Lord Lytton in the 1878 mission to Kabul which the Afghans refused to let proceed. This refusal was one of a series of events which led to the Second Afghan War. In May 1879, Yakub Khan travelled to Gandamak, a village just outside Jalalabad and entered into negotiations with Cavagnari as a result of which the Treaty of Gandamak was signed whereby the Amir ceded territories to the British and accepted a British envoy in Kabul. Cavagnari took up the post of British Resident in Kabul in July 1879. He was known to be reckless and arrogant rather than discreet and his role as envoy was viewed as injudicious even by some of the British. The situation in Kabul was tense and eventually some Afghan troops who had not been paid by the Amir rebelled and attacked the Residency, killing Cavagnari and his mission in September 1879. The war was far from over despite the treaty and British troops were recalled over the mountains to occupy Kabul, secure it and launch punitive action against the Afghans. Yakub Khan