Sher Ali Khan
Sher Ali became Amir of Afghanistan on the death of his father, much to the chagrin of his elder half-brothers, Afzal and Azim. The early years of his rule saw battles between the siblings with victories and defeats for both sides resulting in a temporary loss of the throne to Afzal which passed to Azim on his death. Sher Ali soon won back the seat at Kabul and was now able to strengthen ties with the Anglo-Indian government, newly headed by Lord Mayo. This went well at first, even when Northbrook replaced the assasinated Mayo, but when some disputed Afghan territory was mostly awarded to the Persians, and with Russia ever advancing towards the Oxus, relations became strained.
Sher Ali had always wanted to keep foreign ambassadors out of Kabul, but a change in the British government brought about a 'forward policy' in relation to Afghanistan, which was further strengthened by one of its chief advocates, the new Viceroy in India, Lord Lytton. When the Tsar sent an unexpected envoy to Kabul, and Sher Ali refused a British one, war was declared on the Afghan ruler and the British invaded.
The British victories at Ali Masjid and the Peiwar Kotal convinced Sher Ali to leave his capital, and he made for Tashkent, placing his unfavoured son, Yakub, in charge. Refused military help by the Russians, in low spirits and poor health, Sher Ali died at Mazar-i-Sharif in February 1879.
Yakub Khan
At a young age, Yakub Khan had been put in charge of Herat by his father, the new Amir, and had gone on to help him fight battles against his rivals for the throne, Afzal and Azim. But when Sher Ali decided to nominate his favourite son, Abdullah Jan, as his heir, mistrust arose between Yakub and his father, resulting in Yakub fleeing to Herat with his brother, Ayub. Negotiations smoothed relations, but the official nomination of Abdullah again brought strong protests from Yakub, the results of which saw him imprisoned at Kabul.
In August 1878 Abdullah Jan had died, and when his mourning was compounded by the British invasion coming ever closer to Kabul, Sher Ali fled and released Yakub to take charge in his absence. Yakub Khan inherited the Amirship on his father's death the following February, and soon found himself treating with the British at Gandamak, and doing what his father would never do, accepting a British mission into Kabul.
Things did not go well. At Kabul in September Herati troops ignited a revolt and the British mission was anihilated with Yakub powerless to intervene. British suspicions varied from his passive protest at the massacre in fear of his own life, to outright complicity, suspicions which did not abate when Yakub voluntarily came into the British camp, with thoughts he may still be commanding his troops to defend Kabul from afar. Whatever the truth, Yakub decided it was safer to abdicate, something the British did not strongly object to, and he was sent to India out of harm's way, while a new friendly Amir had to be found.
Abdurrahman
As Yakub Khan had fought for his father's cause, so did his cousin, Abdurrahman, fight for his father's cause in the battles for power in Afghanistan following the death of Dost Mohammed. When Sher Ali finally took the throne for good, Abdurrahman headed to Russia and quietly bided his time, watching with interest the British intervention in his homeland. Russia had several times advised him to make a bid for the empty seat left at Kabul, but when he eventually returned, it was when he thought the time was right.
For the British, Abdurrahman offered a chance to extricate themselves from a campaign that was unpopular at home, and now politically unpopular too since the Liberals had come back in to government. Despite some hesitation over the long term influence the Russians must have enjoyed over him, negotiations were set in motion and Abdurrahman became the new Amir in Afghanistan. He stayed on good terms with the British yet carved himself out as a strong leader, and when he died in 1901, his son, Habibullah continued in the same vein.