Answer
The Second Anglo-Afghan War, fought between 1878 and 1880, proved decisive in solidifying Abdur Rahman Khan's rule. After defeating the British forces and the previous Afghan ruler, Sher Ali Khan, Abdur Rahman Khan skillfully negotiated the Treaty of Gandamak, securing British recognition of his authority. This victory not only established his legitimacy but also allowed him to consolidate power and begin modernizing Afghanistan.