After the death of Ibn Tulun's son Khumarawayh in 896, the Tulunid state quickly began crumbling from within, and failed to put up any serious resistance when the Abbasids moved to re-establish direct control over Syria and Egypt in 905. Tughj defected to the invading Abbasids under Muhammad ibn Sulayman al-Katib, and was named governor of Aleppo in return; Muhammad al-Katib himself fell victim to court intrigues soon after, and Tughj along with his sons Muhammad and Ubayd Allah were imprisoned in Baghdad. Tughj died in prison in 906, and the brothers were freed shortly after. The sons of Tughj participated in the palace coup that tried to depose the new caliph, al-Muqtadir (reigned 908–932), in favour of the older Ibn al-Mu'tazz in December 908. Although the attempt failed, Muhammad ibn Tughj and his brother were able to avenge themselves for their imprisonment on the vizier al-Abbas ibn al-Hasan al-Jarjara'i, whom they struck down with the aid of Husayn ibn Hamdan. After the coup's failure, the three fled: Ibn Hamdan returned to his native Upper Mesopotamia and Ubayd Allah fled east to Yusuf ibn Abi'l-Saj, while Muhammad fled to Syria.