Ahmad Ibn Tulun was the founder of the Tulunid Dynasty. He was born in 853. His father was a Turkish slave who was sent to Baghdad by the Governor of Bukhara, as a present to the Abbassid Caliph, El-Ma'mun. Ahmad Ibn Tulun learnt Arabic and studied Koran, the science of law and many other religious books. Moreover, he took a military course at Samarra and became very competent and well-qualified. In 868, the Emir Bakbak was appointed Governor of Egypt. Then, he sent his stepson, Ahmad Ibn Tulun, as his representative at Fustat.
When Ahmad Ibn Tulun arrived to Egypt, he had to compete with Ibn el-Mudabbir. Ibn el-Mudabbir was one of the famous figures who had a very close relation to el-Mutawakel, the Caliph and one of his high officials. The Caliph appointed him to be responsible for the Kharaj tax in Egypt and more than other seven jobs. Ibn el-Mudabbir ill-treated the Egyptians and used violent, abusive ways in collecting the Kharaj. When Ahmad Ibn-Tulun came to Egypt, he became the Chief of Administration and Prayer, while Ibn el-Mudabbir was the Chief of Finance and collecting the Kharaj. Ahmad Ibn Tulun refused to leave Ibn el-Mudabbir collect the money and ill-treat the Egyptians in this way. So Ibn el-Mudabbir, decided to keep Ibn Tulun in his side by sending him gifts, horses and slaves, but the latter refused to take these gifts and returned them to the former.
Ahmed Ibn Tulun Mosque
Moreover, Ibn Tulun wanted to reduce from the rank of Ibn el-Mudabbir between people. To achieve this goal, he sent to Ibn el-Mudabbir, asking for compensation for the "100" slaves, who were serving el-Mudabbir everywhere. As a response, Ibn el-Mudabbir plotted against Ibn Tulun and sent to the Caliph, saying that Ibn Tulun was trying to be independent from the authority of the Caliphate. But as a counter plot, at that time, Ibn Tulun sent gifts to the Caliph, asking him to appoint Mohamed Ibn Helal, instead of Ibn el-Mudabbir and the Caliph agreed. But on Ibn el-Mudabbir's refusal, Mohamed Ibn Helal put him in prison. Later, when El-Mutamid, the Caliph came to Egypt, he appointed Ibn el-Mudabbir on the Kharaj tax again. Then, he appointed him on the Kharaj tax of Syria and Jordan. After a short time, the governor of Bilad el-Sham (Syria) escaped. So, Ibn Tulun invaded Syria, arrested Ibn el-Mudabbir and put him in prison until he died in it.
Among other big issues, Ahmad Ibn Tulun had to face the revolutions of the Alides, who where angry with the Abbassids, who retained the caliphate for themselves. The first revolution was led by Bagha El-Asghar. Bagha El-Asghar stayed in an area between Barqa (Libya) and Alexandria. Then, he went with his followers to Upper Egypt, but Ibn Tulun sent an army to him and succeeded in defeating him and cutting his head, sending it to Al-Fustat. The second revolution was led by Ibrahim Ibn Mohamed (known as Ibn El-Sofi) who stayed in Upper Egypt, where he stole many places. Then, Ibn Tulun sent an army that eventually failed to achieve victory on El-Sofi. Then, Ibn Tulun sent another strong army, which succeeded in killing most of the followers of Ibn El-Sofi, who escaped to the Oasis, then to Aswan, then to the Red Sea and, finally, to Mecca, where its governor arrested him and sent him to Ibn Tulun. El-Sofi was put in prison, but later, Ibn Tulun set him free.
The third revolution was led by Ahmed Ibn Isa Ibn el-Sheikh, son of the governor of Palestine and Jordan. After the death of his father, he invaded Damascus and refused to pay the yearly Kharaj tax to the Caliph, instead, he took up the money for himself. Then, he found the troubles happening in Baghdad a great chance to invade Bilad el-Sham (Syria) and Egypt, but the Abbasid Caliph, El-Mutawakel, ordered him to be the ruler of Armanya and to leave Bilad el-Sham. Simultaneously, the Caliph sent to Ibn Tulun to go to Syria to fight Ibn el-Sheikh and promised him to be the ruler of Bilad el-Sham, if he could succeed in defeating the latter. However, the Caliph was afraid of the increasing authority of Ibn Tulun in Bilad El-Sham. So, he ordered Ibn Tulun to return back to Egypt and to appoint another leader to the army to defeat Ibn el-Sheikh. Furthermore, there were other revolutions against Ibn Tulun, such as the revolution of Abdel-Rahman el-Amery in Upper Egypt who was killed by his followers and the revolution of the people of Barqa in 875, but Ibn Tulun sent an army to them and succeeded in defeating them after long battles.
When Ibn Tulun went to El-Sham to put down revolts there, he left his son, El-Abbas, to run the affairs of Egypt and he also left to his son an assistant called, El-Wasitty. Then, the troubles and problems happened between El-Abbas and El-Wasitty when the latter refused to appoint some of El-Abbas's friends in the administration, which sparked hatred between them both. Suddenly, El Abbas declared himself as the Ruler of Egypt. Moreover, he went to North Africa and said that the Caliph appointed him Governor of North Africa. Knowing his son's practices, Ibn Tulun sent to him asking that he abstain these actions or he would curse him after each prayer, but his son did not. So Ibn Tulun decided to send an army to arrest him and put him in prison, until he died, during the reign of his oldest brother Khumarawaih. 
Bakbak, the official governor of Egypt, was killed. But fortunately, the Emir Bargug (the father of Tulun's wife) was appointed the new Governor of Egypt and gave Ibn Tulun the full control in Egypt, especially in Alexandria. Ahmed Ibn Tulun had a very strong character and, when the governor of the land changed, Ibn Tulun tried to make a treaty with the new one (El-Muwaffak), who was the Caliph's brother and who prepared an army to depose Ibn Tulun from his position. But El-Muwaffak could not send his army because of the lack of money.
Ahmad Ibn Tulun sent many gifts and money to the Caliph and, therefore, he obtained the independence of Egypt from the Caliph. After the death of Magur (the governor of Syria), Ibn Tulun went to Damascus and the people as well as the officials of Syria welcomed him. Then, he went Tarsus and extended his kingdom from Euphrates and the borders of the Byzantine Empire to Barqa and Aswan. He also fought against the Romans and defeated them near Tarsus. At first, Ibn Tulun was the representative of the Governor of Egypt, but his position was not firm and safe, because of the conflict between him and Ibn el-Mudabbir. When Ibn Tulun got rid of Ibn El-Mudabbir, he had the full control of Egypt and he was collecting the taxes sending the Kharaj to the Caliph. Then, he stopped sending the Kharaj to the Caliph, became the sole ruler of Egypt and became the only one to appoint the high officials, leaders of the army, judges and all members of the government with his borders extended to Syria and Barqa. He established a mint for making coins and he minted the gold dinars, known as Ahmadieh. He tried to protect El-Mutamid, the Caliph from his brother, El-Muwaffak, but the latter arrested the former.

Abu El Gueysh Khumarawaih 

After the death of Ibn Tulun, the army held a conference and appointed the son of Ibn Tulun, called Khumarawaih, ruler of Egypt. Khumarawaih followed the same policy of his father and continued to attack El-Muwaffak in his orations and decided to invade Syria to defeat him. He sent a large army to Syria, while El Muwaffak went to Baghdad with his army, where some governors supported and provided him with equipment. The two armies met near the Orontes River. After a short battle, Khumarawaih was defeated and returned to Egypt, leaving his army to finish the battle. Then, the remains of the Egyptian army succeeded in defeating the enemy. When the news reached Khumarawaih, he went to Syria again and entered Damascus. Then all of Khumarawaih, the Caliph, the son of the Caliph and the Caliph's brother, El-Muwaffak signed an agreement, according to which Khumarawaih became the governor of Egypt and Syria for about 30 years.
After the victory of Khumarawaih and his agreement with the Caliph, he became the chief of Mosul and Barqa, Armenia, Tarsus and other cities. Then, after a short time, the Caliph and El-Muwaffak died and a new Caliph, called El Mo'tadid, ascended the throne. Khumarawaih sent him rich gifts and money. Therefore, the new Caliph extended the authority of Khumarawaih between Barqa and Euphrates, conditioning that "Khumarawaih should pay 300,000 dinars to the Caliph every year". The Caliph, El Mo'tadid, married the daughter of Khumarawaih who was called Qatr En-Nada. Khumarawaih spent 400,000 dinars on this marriage, paying a huge dowry and securing the way of his daughter to Baghdad. After his death, the Tulunid Dynasty became very weak and the Caliph sent his army to enter Egypt.

Egypt Under the Abbasides Again 

Over 37 years, during the reign of Ibn Tulun, Egypt gained a high importance and enjoyed prosperity and stability. After his death, Egypt became an unstable province for 30 years and it remained weak until Muhammad Ibn Tughg the Ikhshid came to Egypt. He was appointed Governor of Egypt in 935. He was given the title of Ikhshid (which means 'prince' in Persian) in 937, the name he gave to his dynasty. This title allowed him to rule somewhat independently of the Caliphate. From 935 and until his death, he ruled the country under the symbolic order of the Baghdad Caliphate. Bin Tughj purchased Abu al-Misk Kafur as a slave in 923 and, recognizing the slave's potential, made him a tutor to his children and a military officer. Eventually, al-Misk gained so much power that he succeeded Bin Tughj.

Egypt Under the Tulunid Dynasty

The Administration Egypt was divided into 3 parts:Upper, Middle and Lower Egypt. It had several nomes, ruled by directors who helped carrying out all the projects of Ibn Tulun, especially taxes collection. Ibn Tulun was responsible for: All public affairs , The army and Public security. 
Ibn Tulun increased the number of soldiers in the army to 100,000 men who were mainly Egyptians, Greeks and Turks. He built more than 100 warships and fortified the ports of Egypt. He restored the port of Alexandria and its lighthouse. Khumarawaih, on the other hand, formed strong, brave and special bodyguards in Wadi Hoaf.
Ibn Tulun gave great interest to agriculture. He built new roads and repaired the old ones. In addition, he dug many canals and cleared them. During his rule, the Nile remained on its normal level, so there was no famine and generally his reign was peaceful and prosperous.
The Nile was the main mean of communication where the products were transported to Damietta, and then, to Alexandria. Also, there were trade relations with Nubia, from which Ivory, ebony, feather, elephants' tusks as well as many other goods were imported. The geographical position of Egypt and its wealth during the Tulunid reign made it an important center between the East and the West and the trade of slaves, incense, musk to Europe and Asia Prospered.
When Ahmad El Mudabbir was responsible for collecting the taxes, he ill-treated the Egyptians and collected heavy, abusive taxes. When Ibn Tulun got rid of El Mudabbir, he looked after the taxes and collected them regularly and justly. When he decided not to send the Kharaj to the Caliph and saved the treasury for himself, he could save a big fortune every year, which helped him carrying out all his political projects. It was said that after the death of Tulun, ten millions dinars were found in the treasury and this explains how Tulun's son, Khumarawaih, spent 400,000 on the marriage of his daughter, Qatr El Nada.
Ahmed Ibn Tulun chose a site between Fustat and Mokattam Hills to build the royal city, known as El-Katai. This city was given this name because it was divided into parts; each part had a different nationality and class. This city consisted of: a great race square, royal palace, great mosque which still stands, pharmacy, hospital beside the mosque, excellent markets, baths, as well as a big garden. Ibn Tulun repaired the Nilometer at the Island of El-Roda. When Khumarawaih became a governor, he enlarged and expanded the palace converting the race square into a garden, decorated with all kinds of flowers, birds in order to stay at it at night.