The British had grown to be a paramount power in India in the course of the 18th and early 19th century. About the time that the Aga Khan was having troubles in Iran, the British were deeply involved in Afghanistan, and their efforts were aimed at establishing in Kabul a rule that would be friendly to Britain, and prevent the Russian influence penetrating the borders of India, that would possibly threaten the existence of British empire. The First Anglo-Afghan War, or First Afghan War (1255/1838 to 1258/1842), which is called for heavy sacrifices and untold hardship and suffering, was undertaken partly to counter the Russian advance in Central Asia and partly to place on the throne at Kabul the dethroned ruler, Shah Shuja, in place of Dost Muhammad (1791-1863). Thus, the British occupied Afghanistan on August 7, 1839, and placed Shah Shuja (1780-1842), the amir of Sadozai tribe on the throne of Kabul and Kandhar. Sir William MacNaghten (1839-1891) was designated as the British envoy at the court of Shah Shuja.
By the end of 1840, the signs of revolts among the Durrani and Gilzay tribes became apparent against the presence of the British in Afghanistan, and the puppet rule of Shah Shuja. Yar Muhammad Khan, the ruler of Herat also contemplated an attack on Kandhar, and had sent a secret mission to the Iranian governor of Mashhad for acquiring aids to expel the British from Afghanistan. Thus, the position of the British envoy, Major Elilliott D'arcy Todd (1808-1845) became impaired in Herat in spite of the treasures he had given to the ruler. In January, 1841 Yar Muhammad demanded further money which, Major Todd knowing his intrigues, refused to pay a penny more until Yar Muhammad gave him guarantee of good conduct, such as admitting a British garrison to Herat. Yar Muhammad refused and insisted on payment of the British subsidy as usual. Thus, Todd himself withdrew from Herat on February 10, 1841, resulting the British mission to Herat ended in failure. The internal risings in Kandhar however were put down by the British commander, General Nott in consultation with Major Henry Rawlinson (1810-1895). The British position in Kandhar, nevertheless, was yet insecure.
Inside Afghanistan, the Aga Khan began to trek from Girishk to Kandhar. On August 6, 1841 the intelligence from Girishk reached Rawlinson, reporting the arrival of the Aga Khan and his hundred horsemen. Rawlinson in turn informed to MacNaghten of the Aga Khan's influence and of his importance as an Iranian refugee in Afghanistan. Henceforward, a close relation developed between the Aga Khan and the British. From Girishk, the Aga Khan had reported his arrival to Muhammad Taymur, the Birtish appointed governor of Kandhar, and also to Major Henry Rawlinson. Soon after his arrival in Kandhar, the Aga Khan sent a letter on October 21, 1841 to Sir William MacNaghten (1839-1891), the British envoy at Kabul, expressing his reasons for leaving Iran that, "Since the conduct of the Iranian government has been so opperssive that all the respectable people and nobles of Iran, particularly those of Iraq, Fars and Kirman have been reduced to vexatious misery, the whole body of the learned men, governors and chiefs induced to throw off the yoke of the Iranian allegiance and protect the wretched people." The Aga Khan stayed on as a guest of Muhammad Taymur at Kandhar. He lived very extravagantly in a large house with all his horsemen and servants, and received his allowances monthly from the Afghan revenues, that is 500 rupees for himself and 25 rupees for his each horseman. The number of horsemen he had brought with him was hundred, but later on the number was increased to three hundreds.
The internal revolts in Kandhar were put down by October, 1841 by Nott, in which Akram Khan, the chief of Durrani tribe was executed, resulting a disaffection among the other tribes, and a very serious outbreak took place at Kabul too in November, which gradually spread to Kandhar. The British position became critical and in the ensuing struggle, the Aga Khan as the ally of the British, was necessarily involved. Rawlinson also made use of the Aga Khan's influence among the Shiite group, to bring about the success.
In November, 1841, the eastern Gilzays broke into revolt near Kabul in protest against the reduction of their allowances, and occupied the passes on the road to Jalalabad, plundered and cut off the communications of Kabul. On November 2, the insurrection broke out in Kabul and Sir Alexander Burnes (1805-1841), MacNaghten's deputy was murdered. The British lost control of Kabul. MacNaghten tried to negotiate with the raiders, but on December 23, he was too murdered and the condition of the British at Kabul became very critical.
The insurrection spread slowly towards Kandhar. Muhammad Ata Khan was sent by the Kabul party to win the Durranis, and thereby raised an insurrection in Kandhar. To encounter this move, Rawlinson also tried to win the favour of the Durranis against the revel Barakzais. But on December 27, a force of Janbas murdered their British officer, Lieut. Colding at Kandhar. Meanwhile, Safdar Jang, a brother of Muhammad Taymur also joined the Durranis. To put down the rising, William Nott (1782-1845) on January 12, 1842 fought with the rebels and defeated them. The Aga Khan had also joined Nott and Rawlinson in the skirmish of Killashek with his 100 horsemen. One of the Aga Khan's men was killed and few others were wounded. Rawlinson, in his report on the Aga Khan mentioned, regarding the event of January 12, that, "On this occasion, Agha Khan, having volunteered the services of his hundred men, was present and was engaged in skirmishing with the enemy."
After two months, the rebel group near Kandhar, prepared for a big incursion under the direction of Mirza Ahmad. The British were in a difficult state. Money was scarce and so was fodder for the cattle. There were no medicines for the wounded in the camp. On March 7, 1842, Nott resolved to give a severe blow to the rebels. On this occasion, Rawlinson in consultation with Nott formed a Parsiwan troop, with the horsemen of the Aga Khan and other Shia chiefs, Nabi Khan and Mirza Ibrahim and placed altogether 300 cavalry under the command of the Aga Khan. Nott with his forces marched out of Kandhar in pursuit of the enemy and some small skirmishes took place on March 9. On the following day, Nott continued his onwards marching. Captain Neill, an eye-witness, in his book, "Recollections" (p. 179) mentioned, "A small body of cavalry, commanded I believe, by Meerza Ahmed, who was kept out to employ and deceive us, molested our rear for a short time; they were, however, driven back by Aga Khan, a Persian refugee Prince, who with about two hundred (it was 300) followers, had accompanied our force from Candahar, and rendered our rearguard some very valuable assistance." Rawlinson in his report, dating December 20, 1842 to Governor General, also mentioned that the services at that time of the Aga Khan were such consequence, "that the general thought him deserving of special notice in the report that was forwarded to the government on the occasion." As the year 1258/1842 progressed, the state of Afghanistan still remained more critical. In July, Kandhar and Jalalabad were still under the British advanced posts, and the intervening valleys and defiles were in the hands of the Afghans.
Meanwhile, Lord Ellenborough (1841-1844), the Governor-General had arrived in India in succession to Auckland and he decided that the British troops should evacuate Afghanistan. In July, 1842 the Aga Khan too learned the evacuation programme of the British. Nott with his troops retreated via Ghazna, Kabul and Jalalabad, and the remaining troops were to return to India via Quetta and Sukkur. The charge of Kandhar was left in the hands of Safdar Beg. The Aga Khan also proposed to accompany the forces retiring to India.