Ahmad Niyaltigin was the treasurer of a sultan who rose to power by seizing what from his younger twin?
Mas'ud I of Ghazni Mas'ud I of Ghazni (Persian: مسعود غزنوی‎ ‎ ), known as Amīr-i Shahīd (امیر شهید ; "the martyr king")(998 – 17 January 1040), was "sultan" of the Ghaznavid Empire from 1030 to 1040. He rose to power by seizing the Ghaznavid throne from his younger twin Mohammad, who had been nominated as the heir upon the death of their father Mahmud of Ghazni. His twin was shortly blinded and imprisoned. However, when much of Mas'ud's western domains had been wrested from his control, his troops rebelled against him and reinstated Mohammad to the throne.
Al-Mu'tasim Abū Isḥāq Muḥammad ibn Hārūn al-Rashīd (Arabic: أبو إسحاق محمد بن هارون الرشيد‎ ‎ ; October 796 – 5 January 842), better known by his regnal name al-Muʿtaṣim bi’llāh (المعتصم بالله , "he who seeks refuge in God"), was the eighth Abbasid caliph, ruling from 833 to his death in 842. A younger son of Harun al-Rashid, he rose to prominence through his formation of a private army composed predominantly of Turkish slave-soldiers ("ghilmān"). This proved useful to his half-brother, Caliph al-Ma'mun, who made use of al-Mu'tasim and his Turkish guard to counterbalance other powerful interest groups in the state, as well as employing them in campaigns against rebels and the Byzantine Empire. When al-Ma'mun died unexpectedly on campaign in August 833, al-Mu'tasim was thus well placed to succeed him, overriding the claims of his nephew, al-Abbas ibn al-Ma'mun.