A series of wars between Afghan rulers and British India. The first occurred (1838–42) when Britain, concerned about Russian influence in Afghanistan, sent an army to replace Dost Muhammad with a pro‐British king, Shah Shuja al‐Mulk. Resistance to Shuja's rule culminated in an uprising (1841), which led to the destruction of the British Indian forces in Kabul during their withdrawal to Jalalabad (1842). Kabul was reoccupied the same year, but British forces were withdrawn from Afghanistan. The second (1878–80) was also fought to exclude Russian influence. By the Treaty of Gandamak (1879) Britain acquired territory and the right to maintain a Resident in Kabul, but in September of the same year the Resident, Sir Louis Cavagnari, was killed in Kabul and further campaigns were fought before the British withdrawal. The third war was fought in 1919, when the new amir of Afghanistan, Amanullah, attacked British India and, although repulsed, secured the independence of Afghanistan through the Treaty of Rawalpindi (1919).