During the Khivan campaign of 1873, he attacked Khanate of Khiva, took the capital, and forced the Khan to become a vassal of Russia. This was followed in 1875 by the campaign against Kokand, in which Kaufman defeated the uprising khan, Nasreddin, after an anti-Russian uprising against the previous ruler, Khudoyar. The fiction of Kokand's independence was ended, and the remaining rump of the Khanate in the Ferghana Valley was annexed. This rapid absorption of these Khanates brought Russia into proximity to Afghanistan, and the reception of Kaufmann's emissaries by the Sher Ali Khan was a main cause of the Second Anglo-Afghan War.