Second Anglo-Afghan War (1878–80) first led to the
British defeat followed by their victory at the
Battle of Kandahar, which led to
Abdur Rahman Khan becoming the new emir and the start of friendly British-Afghan relations. The British were told they would be given control of Afghanistan's foreign affairs (Afghanistan didn’t let them have that control even when the deal was made) in exchange for protection against the
Persians, large sums of money and complete withdrawal of British forces from Afghanistan. The
Third Anglo-Afghan War in 1919 led the British to give up control of Afghanistan's foreign affairs finally in 1921.