Ghazna, initially installed them as governors of Sanjah. However, their efficient administration of the province, made him doubtful of their uprise and seeing a possible challenge to his own authority, he ordered his nephews to be imprisoned in the castle of Gharjistan. Although, they were released from the captivity by his son Sayf al-Din Muhammad after the death of his father in 1161. Sayf al-Din, later died in a battle against the nomadic Oghuzs of Balkh. ‌After their release from the captivity, "Tarik-i-Firishtah" states that the Ghurid brothers were reinstated in Sanjah, although earlier account of "Tabaqat-i-Nasiri" stated that the hardship continued due to their financial conditions. Muhammad thus, took shelter in the court of his uncle Fakhruddin Masud who held the principality of Bamiyan as vassal of Alauddin Husayn. Later, Fakhr al-Din Masud laid his own claim for the succession after Sayf al-Din death as the elder member of the Ghurid family. Muhammad of Ghor helped his brother in suppressing the revolt of Fakhruddin who garnered a sizeable army in alliance with the chiefs of Balkh and Herat who both were executed in the battle, although Fakhruddin was reinstated in Bamiyan in 1163. Afterwards, with support of the remaining local Ghurid officers and "maliks", his brother succeeded Sayf al-Din to the throne in 1163 and initially placed Muhammad as a minor officer in his court, which result in him retiring (unhappy with his position) to the court of Sistan where he spend a whole season. However, later Ghiyath-al din sent an envoy to brought him back who subsequently placed him in charge of the southern part of the Ghurid domains which possibly included Istiyan and Kajuran. ‌ During the early campaigns of Muhammad of Ghor as a prince, he was instructed to subdue the Oghuz tribes whose power and influence began to wane, although they were still controlling extensive territories. He used Qandhar as a base and raided the principality of Oghuzs multiple times, before defeating them decisively along with Ghiyath al-Din and followed up their victory by conquering Ghazna in 1169 along with some other territories in what is present-day eastern Afghanistan. Soon, his coronation took place in Ghazna in 1173 and his brother returned to Firuzkuh for the westwards expansion in Transoxania. In 1174, he led an expedition against the Ghuzzs of Sanquran in present-day Turkmenistan and subdued them. In 1175, Muhammad of Ghor marched from Ghazna