# Muhammad ibn Ali al-Khalanji

Muhammad ibn Ali al-Khalanji or Ibrahim al-Khaliji or Muhammad ibn al-Khalij (Egyptian Arabic: محمد بن الخليج; possibly d. 905 AD) was one of the senior commanders of the Tulunid dynasty, who rebelled against the Abbasid Caliphate after the fall of the Tulunid emirate.

## Early life

He was an Egyptian officer born in the Bay of Fustat and that's where the name "ibn al-Khalji" come from.
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.

## Restoration of Independence

After the fall of the Tulunid dynasty and the entry of the Abbasid armies into Egypt, the Abbasids committed crimes against humanity against Egyptians, whether soldiers or civilians. 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.”
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. In one of these batches, there was an Egyptian officer named Mahammad bin al-Khalij or Mahammad bin Ali al-Khalanji.
On the way to Baghdad, the officer, Mahammad ibn al-Khalij, conspires with the captured officers, specifically with the Egyptian officer, Shafi’ al-Lulu’i. Thousands of Egyptian soldiers are liberated and attack the Abbasid soldiers. They are freed from captivity and return to Egypt.
On the way to the Egyptian army liberating Egypt, they entered the city of Ramla in Palestine and defeated the Abbasid army there, whose leader was Wasif bin Sawartkin the Younger. 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. After that, the Egyptian army moved under the leadership of Ibn al-Khalij, and at Gaza they were met by the Abbasid army stationed in Egypt The Egyptian army won a landslide victory, then moved towards Arish and defeated the Abbasid garrison there, then to Farma and defeated the Abbasids there.
After that, the Abbasid governor of Egypt, Isa al-Nushari, prepared a very large army and met the Egyptian army at Bilbeis in Sharqia. There the Egyptians won another decisive victory, and the road to the Egyptian capital, Fustat, was opened. As for the Abbasid governor al-Nushari, who heard of the defeat of the Abbasid army, he fled from Fustat with the remains of his commanders.
After that, the victorious Egyptian army, led by Ibn al-Khalij, entered the city of Fustat. 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).

## Ruling Egypt

Ibn al-Khalij worked to calm things down and eliminate the chaos in Egypt. 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.
When Ibn al-Khalij entered Fustat, the Egyptians decorated themselves and the streets with saffron, and the barbers came and washed and shaved the hair of Ibn al-Khalij's horse.
Ibn al-Khalij settled in the city of Fustat after he was confident that his rule was stable in Fustat and the Delta. Ibn al-Khalij ordered the necessity of the official return of the Egyptian army and the opening of the door to volunteering for all Egyptians. People came to him from all over Egypt to volunteer for his army, to the point that the Egyptian army under his rule became fifty thousand, which was a large number at the time.
After that, al-Khalanji still wanted to get rid of the Abbasid presence as quickly as possible, so he ordered a commander named Khafif al-Nubi to eliminate the remnants of the Abbasids in Egypt. Indeed, the Abbasids fled from the first time they heard of the Egyptian army's movement from Fustat, and they were forced to flee to Alexandria, then to the village of Turuja in Beheira, and there the Abbasids set a trap for Commander Khafif. Khafif who fell into the trap was forced to withdraw to Fustat. The remnants of the Abbasids fled to Upper Egypt, led by the former governor of Egypt, Isa al-Nushari.

## Fall

At that time, the Abbasid Caliphate sent land and sea forces to support al-Nushari, by land under the leadership of Abu al-Az Khalifa bin Mubarak al-Sulami, and by sea under the leadership of Damian of Tarsus. Thus, the situation became dangerous for Ibn al-Khalanji in front of the Abbasid Caliphate's army and fleet coming from the north, and the army of Isa al-Nushari coming from the south in Upper Egypt.
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. The Egyptian army, led by Ibn al-Khalanji, was victorious in the Battle of al-Arish in the year 293 AH. In this battle, a large number of Abbasid soldiers were captured. After that, Ibn al-Khalij found another Abbasid army coming by land under the command of Fatik al-Mutaddi by land, and Damian's forces by sea.
After that, Ibn al-Khalij found another Abbasid army coming by land under the command of Fatik al-Mu'tadidi by land, and Damian's forces by sea. Indeed, Ibn al-Khalanji defeated Fatik and his army more than once, but unfortunately, the last time, Ibn al-Khalanji was defeated at Beni Suef after valiant resistance.
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.
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. There, he and his companions were tortured in Baghdad, and the Abbasid Caliph ordered them to be slandered over camels, then he ordered his killing, in order to thus end this temporarily successful attempt to restore the Tulunid state, which cost Ibn al-Khalanji the lives of him and many Egyptians.