The Treaty of Gandamak (Dari: معاهده گندمک, Pashto: د گندمک تړون) officially ended the first phase of the Second Anglo-Afghan War. The Afghan emir Mohammad Yaqub Khan ceded various frontier areas as well as Afghanistan's control of its foreign affairs to the British Raj.
It was signed on 26 May 1879 by King Mohammad Yaqub Khan of Afghanistan and Sir Louis Cavagnari of the British Government of India at a British army camp near the village of Gandamak, about 70 miles (110 km) east of Kabul. The treaty was ratified by Lord Edward Robert Bulwer-Lytton, Viceroy of India, on 30 May 1879.