 In 1008 he played a leading role in a battle against the Karakhanids at Sharkhiyan near Balkh, in which the Ghaznavids were victorious.By 1011 he had been made governor of Herat by Sabuktigin's son, Mahmud of Ghazni.In 1017 Mahmud conquered Khwarazm from its Ma'munid rulers, and made Altun Tash its governor.