The Second Anglo-Afghan War (Pashto: د افغان او انگرېز دويم جنگ; Persian: جنگ دوم افغان و انگلیس) was a military conflict fought between the British Raj and the Emirate of Afghanistan from 1878 to 1880, when the latter was ruled by Sher Ali Khan of the Barakzai dynasty, the son of former Emir Dost Mohammad Khan. The war was part of the Great Game between the British and Russian empires.
The war was split into two campaigns – the first began in November 1878 with the British invasion of Afghanistan from India. Sher Ali Khan opted to leave Kabul in order to seek political and military aid from the Russian Empire, and died in Mazar-e Sharif trying to reach the Russian border, leaving the throne to his son Mohammad Yaqub Khan. Ali's successor Yaqub immediately sued for peace and the Treaty of Gandamak was then signed on 26 May 1879. The British sent an envoy and mission led by Sir Louis Cavagnari to Kabul, but on 3 September this mission was massacred and the conflict was reignited by Ayub Khan which led to the abdication of his brother Yaqub.