Answer
In 1826, Dost Mohammad Khan, a former ruler of Kabul, was proclaimed Emir of Afghanistan. He had been deposed by the British in 1823, but they had been unable to hold on to power and he had returned to Afghanistan. He was able to defeat his rivals and establish himself as the ruler of the country.