The Durrani dynasty diminished in the early 19th century when Afghanistan was fighting defensive wars with Persia on one side and British India on the other side. The Barakzai dynasty took over control of the kingdom but lost many of Afghanistan's territories by the end of the 19th century. It became to what is now Afghanistan after the Anglo-Afghan Treaty of 1919 when the state became officially recognized by all the major countries in the world. At first its capital was in Kandahar as that is where the empire started however the capital then shifted to Kabul after its conquest. The empire had two capitals, the main capital Kabul and the winter capital, Peshawar.