the ghaznavid prince and samanid general sebüktigin, however, managed to defeat the rebels, but soon took control over khurasan, while the remains of the samanid dynasty in bukhara was conquered by the kara-khanid khanate. isfaraini shortly changed his allegiance to the ghaznavids, where he rose to prominent offices. in 997, sebüktigin died and was succeeded by his son ismail, who soon, however, was defeated by his brother mahmud, who crowned himself as the new ruler of the ghaznavid dynasty, and shortly appointed isfaraini as his vizier, thus making isfaraini become the first vizier of the ghaznavid dynasty. isfaraini later changed the administrate language of the ghaznavid state from arabic to persian.