Although not a member of the Ghaznavid family, the foundation of the Ghazni as a Ghaznavid city can be attributed to the Turkic slave commander of the Samanid Empire, Alp-Tegin, who after his unsuccessful attempt to put the Samanid prince Nasr on the throne, was forced to flee from the court in Bukhara. In 963, Alp-Tegin accompanied by his personal guard of Turkic slave-soldiers and group of Iranian ''ghazis'' left for Ghazni, which was a small town in Zabulistan ruled by the local Lawik dynasty. He seized Ghazni from Abu Bakr Lawik, a kinsman of the Kabulshah, and secured his position by receiving an investiture from the Samanids as the governor of Ghazni.