Salm left Ibn Khazim in charge of the province after fleeing in the wake of the successive deaths of caliphs Yazid and his son Mu'awiya II in 683 and 684, which caused the collapse of Umayyad rule. Ibn Khazim gave his allegiance to the Mecca-based caliph Abd Allah ibn al-Zubayr. Early on, he contended with mutinies by troops from the Rabi'a tribe and the military governors of Herat and Marw al-Rudh, who both hailed from the Banu Bakr tribe. He was assisted in their suppression by troops from the Banu Tamim, another large tribal faction from which many Khurasani Arab troops hailed. He installed his son Muhammad at Herat while he took up his headquarters at Marw al-Rudh. Afterward, the Tamim revolted, captured Herat and killed Muhammad before turning their attention toward Ibn Khazim. However, before they could move against him, dissension developed among them and their rebel army disbanded. Ibn Khazim's position in Khurasan was strong when the Umayyads under Caliph Abd al-Malik defeated and killed Ibn al-Zubayr and his brother Mus'ab in Mecca and Iraq. Thus, he refused to pay allegiance to Abd al-Malik when the latter demanded it, despite being offered the governorship for a further seven years. In response, Abd al-Malik allied with a factional leader of the Tamim, Bukayr ibn Wisha al-Sa'di, who agreed to eliminate Ibn Khazim in return for the governorship of Khurasan. By the end of the year, Ibn Khazim had been confronted on his way to his son Musa's fortified stronghold at Tirmidh, but was intercepted and killed by Bukayr's troops. According to al-Tabari, the troops of a rival Tamimi commander, Bahir ibn Warqa, killed Ibn Khazim in the village of Shahmighad, north of Marw, but Bukayr seized Ibn Khazim's severed head and sent it to Abd al-Malik taking credit for the slaying. Before he died, Ibn Khazim reportedly spat at his killer, a tribesman whose brother Ibn Khazim had previously executed, exclaiming defiantly that he was chief of the Mudar tribal confederation, while his killer's brother was a mere peasant.