The son of Tughj ibn Juff, a general of Turkic origin who served both the Abbasids and the autonomous Tulunid rulers of Egypt and Syria, Muhammad ibn Tughj was born in Baghdad but grew up in Syria and acquired his first military and administrative experiences at his father's side. He had a turbulent early career: he was imprisoned along with his father by the Abbasids in 905, was released in 906, participated in the murder of the vizier al-Abbas ibn al-Hasan al-Jarjara'i in 908, and fled Iraq to enter the service of the governor of Egypt, Takin al-Khazari. Eventually he acquired the patronage of several influential Abbasid magnates, chiefly the powerful commander-in-chief Mu'nis al-Muzaffar. These ties led him to being named governor first of Palestine and then of Damascus. In 933, he was briefly named governor of Egypt, but this order was revoked after the death of Mu'nis, and Ibn Tughj had to fight to preserve even his governorship of Damascus. In 935, he was re-appointed to Egypt, where he quickly defeated a Fatimid invasion and stabilized the turbulent country. His reign marks a rare period of domestic peace, stability and good government in the annals of early Islamic Egypt. In 938 Caliph al-Radi granted his request for the title of "al-Ikhshid", which had been borne by the rulers of his ancestral Farghana Valley. It is by this title that he was known thereafter.