Afghanistan gained complete independence from Britain on August 19, 1919, following the Third Anglo-Afghan War. This conflict ended in a British victory but resulted in Afghanistan being recognized as a fully sovereign state, ending British control over its foreign affairs that had existed since the 1879 Treaty of Gandamak.