The disaster of the First Anglo-Afghan War continued to haunt the British for decades, and the 70 years following the defeat of 1842 were a period of extraordinary vacillation in British policy toward Afghanistan. Not only were political perspectives different in Delhi and London, but there were also changes in government. Imperialists favored the Forward Policy, which held that the defense of India required pushing its frontiers to the natural barrier of the Hindu Kush so that Afghanistan (or at least parts of it, such as Herat) would be brought entirely under British control. In 1874 Benjamin Disraeli became prime minister of Britain and in 1876 a new viceroy (Lord Lytton) was dispatched to Delhi with orders to reinstate the Forward Policy. Sher Ali (also Shir 'Ali), the emir of Afghanistan, rejected a second British demand for a British mission in Kabul (1876), arguing that if he agreed the Russians might demand the same right.
After tension between Russia and Britain in Europe ended with the June 1878 Congress of Berlin, Russia turned its attention to Central Asia. In the summer of 1878 Russia sent an uninvited diplomatic mission to Kabul, headed by Russia's General Stolyetov, setting in motion the train of events that led to the Second Anglo-Afghan War. Sher Ali tried to keep the Russian mission out but failed. The Russian envoys arrived in Kabul on July 22, 1878, and on August 14 the British demanded that Sher Ali accept a British mission. Sher Ali had not responded by August 17 when his son and heir died, throwing the court into mourning.
When no reply was received, the British dispatched an envoy, Sir Neville Chamberlain, with a small military force, which was refused permission to cross the Khyber Pass by Afghan troops. The British presumably considered this an insult, but more likely it was viewed at the highest levels as a fine pretext for implementing the Forward Policy and taking over most of Afghanistan. The British delivered an ultimatum to Sher Ali, demanding an explanation of his actions. The Afghan response was viewed by the British as unsatisfactory, and on November 21, 1978, British troops entered Afghanistan at three points. Sher Ali, having turned in desperation to the Russians, received no assistance from them. Appointing his son, Yaqub, regent, Sher Ali left to seek the assistance of the tsar. Advised by the Russians to abandon this effort and to return to his country, Sher Ali returned to Mazare Sharif, where he died in February 1879.
With British forces occupying much of the country, Yaqub signed the Treaty of Gandamak in May 1879 to prevent British invasion of the rest of Afghanistan. According to this agreement and in return for an annual subsidy and loose assurance of assistance in case of foreign aggression, Yaqub agreed to British control of Afghan foreign affairs, British representatives in Kabul and other locations, extension of British control to the Khyber and Michni passes, and the cession of various frontier areas to the British.
The British resident in Kabul, Sir Louis Cavagnari, was assassinated on September 3, 1879, just two months after he arrived. British troops trudged back over the mountain passes and the Afghan uprising against the British was, unlike that of the First Anglo-Afghan War, foiled in October 1879 with the reoccupation of Kabul. Yaqub abdicated.
Despite the success of the military venture, by March 1880 even the proponents of the Forward Policy were aware that defeating the Afghan tribes did not mean controlling them. Although British policymakers had briefly thought simply to dismember Afghanistan a few months earlier, they now feared they were heading for the same disasters that befell their predecessors at the time of the First Anglo-Afghan War.
Just as the British interventionists were reaching this conclusion, the Liberal Party won an electoral victory in March 1880. This assured the end of the Forward Policy, which had been a major campaign issue. The second British venture into Afghanistan resulted in about 2500 British and colonials killed with some 1500 Afghans killed.