In 1834 he was with Fesal on an expedition against El Hasa when news came of the amir's murder by his cousin Masharah.
This led to long negotiations, and ultimately to war, when the British forced the Khyber Pass in November 1878, and defeated the amir's forces on every occasion.
Although his father, Afzul Khan, who had none of these qualities, came to terms with the Amir Shere Ali, the son's behaviour in the northern province soon excited the amir's suspicion, and Abdur Rahman, when he was summoned to Kabul, fled across the Oxus into Bokhara.
Notwithstanding the new amir's incapacity, and some jealousy between the real leaders, Abdur Rahman and his uncle, they again routed Shere Ali's forces, and occupied Kandahar in 1867; and when at the end of that year Afzul Khan died, Azim Khan succeeded to the rulership, with Abdur Rahman as his governor in the northern province.
In that year Ayub Khan made a fruitless inroad from Persia; and in 1888 the amir's cousin, Ishak Khan, rebelled against him in the north; but these two enterprises came to nothing.
Within the amir's dominions there are probably from four to five millions of people, and of these the vast majority are agriculturists.
The amir's factories at Kabul for arms and ammunition are said to turn out about 20,000 cartridges and 15 rifles daily, with 2 guns per week; but-the arms thus produced are very heterogeneous, and the different varieties of cartridge used would cause endless complications.
When, therefore, the conquest of Khiva in 1873 by the Russians, and their gradual approach towards the amir's northern border, had seriously alarmed Shere Ali, he applied for support to the British; and his disappointment at his failure to obtain distinct pledges of material assistance, and at Great Britain's refusal to endorse all his claims in a dispute with Persia over Seistan, so far estranged him from the British connexion that he began to entertain amicable overtures from the Russian authorities at Tashkend.
Another force under Sir Frederick Roberts marched up to the high passes leading out of Kurram into the interior of Afghanistan, defeated the amir's troops at the Peiwar Kotal, and seized the Shutargardan Pass which commands a direct route to Kabul through the Logar valley.
In June the fort of Girishk, on the Helmund, was seized by his adherents; the amir's troops were defeated some days later in an engagement, and Ayub Khan took possession of Kandahar at the end of July.
Ayub Khan fled toward Herat, but as the place had meanwhile been occupied by one of the amir's generals he took refuge in Persia.
The work went on with much difficulty and contention, until in March 1885, when the amir was at Rawalpindi for a conference with the viceroy of India, Lord Dufferin, the news came that at Panjdeh, a disputed place on the boundary held by the Afghans, the Russians had attacked and driven out with some loss the amir's troops.
Some local revolts among the tribes were rigorously suppressed; and two attempts to upset his rulership - the first by Ayub Khan, who entered Afghanistan from Persia, the second and more dangerous one by Ishak Khan, the amir's cousin, who rebelled against him in Afghan Turkestan - were defeated.
In 1895 the amir's troops entered Kafiristan, a wild mountainous tract on the north-east, inhabited by a peculiar race that had hitherto defied all efforts to subjugate them, but were now gradually reduced to submission.
The amir's first measures were designed to enhance his popularity and to improve his internal administration, particularly with regard to the relations of his government with the tribes, and to the system introduced by the late amir of compulsory military service, whereby each tribe was required to supply a proportionate number of recruits.
It was found impossible, after many interviews, to obtain from Habibullah his consent to any addition to or variation of the terms of the assurance given by the British government in 1880, with which he professed himself entirely satisfied, so that the treaty finally settled in March 1905 went no further than a formal confirmation of all engagements previously concluded with the amir's predecessor.
It was felt in British circles at the time that a very considerable concession to Habibullah's independence of attitude was displayed in the fact that he was styled in the treaty " His Majesty "; but, in the circumstances, it seems to have been thought diplomatic to accede to the amir's determination to insist on this matter of style.
By the agreement of 1893 with the amir most of the Waziri clan and also the Afridis had been left outside the limits of the amir's influence and transferred to the British zone.
They form the bulk of the amir's cavalry.
The recovery of this fortress became the Afghan amir's great concern.
Burnes, however, was unable to prevail on the governor-general, Lord Auckland, to respond to the amir's advances.