Thus the title of hajib was still used for masters of ceremonies and intermediaries between the ruler to the bureaucracy, but also as a military rank given to generals and provincial governors. Thus in the Samanid dynasty (819–999), which also relied on a Turkic-dominated ghilman corps, the title was originally restricted to the ruler's household, but by the mid-10th century had come to acquire a military role: the "chief" or "great hajib" (al-hajib al-kabir, hajib al-hudjjab, hajib-i buzurg) was the second man in the state, combining in his person the functions of head of the palace and commander-in-chief. Ordinary hajibs served as generals and, occasionally, provincial governors. According to Nizam al-Mulk's account on the training of ghilman, a ghulam could rise through the ranks to withaq-bashi ("tent leader"), khayl-bashi ("detachment commander"), before attaining the rank of hijab, and then become amir of a province. The Samanid practice was emulated by the successor Ghaznavid dynasty (977–1186) as well, with the hajib-i buzurg as the commander-in-chief in the Sultan's stead, commanding several ordinary hajibs as generals; all of them were distinguished by a black cloak, a specific type of belt, and a two-pointed cap. However, unlike the Samanids, the Ghaznavid hajib-i buzurg did not exercise direct control over the palace administration, which was in the hands of the wakil-i khass, nor over the palace guard, which was entrusted to the salar-i ghulaman-i saray. In the Buyid emirates (934–1062), which lacked the sophisticated central government of the Abbasid type, hajib was exclusively a military title. The account of Miskawayh implies that here too there was a succession of ranks, from naqib to qa'id and then to hajib. In the Seljuk Empire (1037–1194), however, the mainly military role of the chief hajib receded somewhat, although, given the military character of the Seljuk court, its occupant was still a Turkish commander (amir), with a staff mostly drawn from ghilman. The amir hajib might still participate in campaigns and command parts of an army, but he was once again mostly a court official, commanding generals being designated as sipahsalar or isfahsalar. The office's role under the Seljuks is described in the writings of Nizam al-Mulk and Muhammad bin Ali Rawandi. Anachronistically ascribing its existence to the practices of the Sasanian court, the latter writes that the hajib was the official responsible for administering punishment. The amir hajib was the highest-ranking court official, and apart from ceremonies