[1][2][3] Ibn al-Khalij was one of the junior officers in a section of the Egyptian Tulunid army headed by Commander Safi al-Rumi, and there is not sufficient information about his upbringing or activity at that time.
[1] The historian Ibn Taghribirdi says about that incident: “They attacked the homes of the people, plundered them, took their money, violated their harems, took the virgins, and did to the Egyptians what they would not do to the infidels.”[1]When the Abbasids first entered Egypt, they disbanded the Egyptian army and captured all the remaining officers and soldiers who remained from the last battle to defend the capital at that time, al-Qata'i, and sent them in batches to Baghdad.
There in Ramla, Emir Mahammad bin al-Khalij ordered the proclamation in the minbars (pulpits) that Egypt had become independent again and that the state of Banu Tulun had returned.
The Egyptian people received the army with ululations and celebrations and prayed for Ibn al-Khalij from the pulpits of the mosques after the Abbasid Caliph and Ibrahim bin Khumarawayh (the last Tulunid prince captured in Baghdad).
Dr. Wafa Mahammad Ali says in his book “Pages from the History of the Abbasids صفحات من تاريخ العباسيين” that Ibn al-Khalij's entry into Fustat restored hope that the Tulunid state would soon return again, and the Egyptians were very happy with great joy due to the intensity of their love for the dynasty and the glory days of Egypt and its independence during their reign.
[1][2][3] But Ibn al-Khalanji was not shaken for a moment and was determined to fight the Abbasids until his last breath, so he went out to meet the army that came from outside at Arish.
[1][2][3] After that, Ibn al-Khalanji was forced to withdraw to Fustat, and at that time the Abbasid fleet entered under the leadership of Damian, and al-Khalanji saw that he was beginning to be effectively defeated in the war, and his position was worsened by the worsening conditions in Egypt due to the large number of wars, to the point of rising prices.
[1][2][3] In the end, the Abbasids entered Fustat by land and sea, and Ibn al-Khalanji was forced, with regret, to hide in the house of a foreign man named Trik, but this man reported him to the Abbasids, so Mahammad Ibn al-Khalij was arrested and sent to Baghdad, along with his closest followers, after he ruled Egypt for nearly a year, specifically seven months and twenty-two days.