Jayapala was the last great king of this dynasty. His empire extended from west of Kabul to the river Sutlej. However, this expansion of Gandhara kingdom coincided with the rise of the powerful Ghaznavid Empire under Sabuktigin. Defeated twice by Sabuktigin and then by Mahmud of Ghazni in the Kabul valley, Jayapala gave his life on a funeral pyre. Anandapala, a son of Jayapala, moved his capital near Nandana in the Salt Range. In 1021 the last king of this dynasty, Trilochanapala, was assassinated by his own troops which spelled the end of Gandhara. Subsequently, some Shahi princes moved to Kashmir and became active in local politics.