In 1834 AD Dost Mohammed Kahn pushed aside Ahmed Shah Durrani‘s grandson to become the ruler of Afghanistan. He found himself caught ruling a small, poor country between two great powers: Russia under Czar Nicholas in the north and Britain, which was pushing north from India in the south.
Dost Mohammed tried to make friends with Britain, but when they weren’t super friendly he switched over to Russia. The British army invaded Afghanistan in 1839, but by 1842 Dost Mohammed’s son forced the British out again, killing thousands of British soldiers and their families. Dost Mohammed then made a deal with the Sikhs against the British.
But the Sikhs surrendered to the British in 1849, and by 1855, with Czar Nicholas dead in Russia, Dost Mohammed also went over to the British side. The next year, Malek Jahan of Iran invaded Afghanistan to try to get some land back for Iran, but Dost Mohammed was able to call on his British allies for help, and in 1856 Afghanistan and Britain attacked Iran.
When Dost Mohammed died in 1863, his son Sher Ali Khan took over. Sher Khan (that’s what Rudyard Kipling named the tiger in his Jungle Book) tried to stay neutral, but by 1878 the British were invading Afghanistan again. In 1880, Sher Khan’s son, Ayub Khan, beat the British army in battle, but after Ayub Khan was killed, the British took over Afghanistan.