Origin and early life
Map of the Tulunid domains ca. 893
According to the biographical dictionary compiled by Ibn Khallikan, Muhammad ibn Tughj was born in Baghdad on 8 February 882, on the street leading to the Kufa Gate. His family was of Turkic origin from the Farghana Valley in Transoxiana, and claimed royal descent; the name of his ancestor, "Khaqan", is a Turkic royal title. Muhammad's grandfather Juff left Farghana to enter military service in the Abbasid court at Samarra, as did the father of Ibn Tulun, the founder of the Tulunid dynasty. Juff and his son, Muhammad's father Tughj, both served the Abbasids, but Tughj later entered the service of the Tulunids, who since 868 had become autonomous rulers of Egypt and Syria. Tughj served the Tulunids as governor of Tiberias (capital of the district of Jordan), Aleppo (the capital of the district of Qinnasrin) and Damascus (capital of the homonymous district). He played a major role in repelling the Qarmatian attack on Damascus in 903; although defeated in battle, he held the city itself against the Qarmatians for seven months until, with the arrival of reinforcements from Egypt, the Qarmatians were driven away. Thus Muhammad ibn Tughj spent a great part of his youth in the Tulunid Levant at his father's side, gaining his first experiences in administration—he served as his father's sub-governor of Tiberias—and war.
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.
In Syria, Muhammad ibn Tughj joined the service of the tax supervisor of the local provinces, Abu'l-Abbas al-Bistam. He soon followed his new master to Egypt, and after al-Bistam's death in June 910 he continued serving the latter's son. Eventually, he gained the attention of the local governor, Takin al-Khazari, who sent him to govern the lands beyond the Jordan River, with his seat at Amman. In 918, he rescued a hajj caravan, among which was one of the ladies-in-waiting of al-Muqtadir's mother, from Bedouin raiders, thereby improving his standing at the Abbasid court. Two years later, Ibn Tughj gained an influential patron when he briefly served under the powerful Abbasid commander-in-chief Mu'nis al-Muzaffar, when he came to help defend Egypt from a Fatimid invasion. During the campaign, Ibn Tughj commanded the finest troops of the Egyptian army. The two men evidently established a rapport, and remained in contact thereafter.
When Takin returned to Egypt as governor in 923, Ibn Tughj joined him there, but the two men fell out in 928 over Takin's refusal to give Ibn Tughj the post of governor of Alexandria. Ibn Tughj escaped the capital Fustat by a ruse, and managed to obtain for himself an appointment as governor of Palestine from Baghdad; the incumbent, al-Rashidi, fled the governor's seat at Ramla for Damascus, whose governorship he assumed. His flight, according to historian Jere L. Bacharach, may indicate that Ibn Tughj commanded a significant military force. Three years later, in July 931, Muhammad ibn Tughj was promoted to governor of Damascus, while al-Rashidi returned to Ramla. Both these appointments were likely the result of Ibn Tughj's relation with Mu'nis al-Muzaffar, who at this time was at the zenith of his power and influence.