The Fatimid Dynasty became very weak for many reasons: the weakness of the Caliphs; the conflicts between the viziers on the throne; the strong famine which happened because of the low level of the Nile; the spread of dangerous diseases (especially plague) and the Caliphs being a game in the hands of the viziers. Then a new danger appeared: the Crusaders came to Egypt and Syria with the excuse of saving the Sacred City of Jerusalem from the Seljuk rulers. In Syria, Nur-Ed-Din Mahmoud (the Islamic warrior) noticed the value of Egypt, so he thought of invading it to siege the Crusaders between two sides. He took the opportunity of the conflict between the two Fatimid viziers (Shawar and Dirgham) to interfere in Egypt's affairs. Shawar, the Arab governor of Upper Egypt, became a vizier after El-Adil Ruzzik. Dirgham succeeded to be the vizier of Egypt to dismiss Shawar from Cairo. Then, Shawar went to Nur-ed-Din at Damascus and asked his help. Shawar offered to pay the cost of the expedition and promised Nur-ed-Din to pay him a third of the revenue of Egypt if he restored his power in Egypt. Knowing that Shawar made a treaty with Nur-ed-Din, Dirgham tried to make strong relations with the Crusaders and the King of Jerusalem against Nur-ed-Din and Shawar. Then, supported by a strong army led by Shirkuh and his nephew Saladin, Shawar came to Egypt. Shirkuh defeated the Egyptians and Crusaders and Dirgham was killed.
When Shawar restored his power, he broke all his promises and refused to pay the tribute. But, he made a strong relation with the Crusaders against the Seljuks. Then, Shirkuh insisted that Nur-ed-Din allow him to invade Egypt, because the government of Egypt was very weak and the country enjoyed no security in it. Finally, Nur-ed-Din gave orders to Shirkuh to invade Egypt with 2000 horsemen. When Shirkuh reached the Nile, at Atfih (south of Cairo), he knew that Amalric left Palestine quickly and went to Egypt as soon as he heard of Shirkuh's move. Amalric's army camped near Fustat, while Shirkuh's army camped at Giza.The two armies met at an area called The Two Gates (El-Baban), south of Minya. Shirkuh defeated Amarlic's army and Shawar's army and the two armies came back to Cairo. But Shirkuh did not follow them. Rather, he went north by a desert route and entered Alexandria without any fight. Shirkuh appointed Saladin Governor of Alexandria and left with him one half of his army. Then, Shirkuh went with the other half to Upper Egypt in order to collect money. Then, the Crusader and Egyptian armies together with the Christian fleet sieged Alexandria. Finally, a peace treaty was signed between the Crusaders and Shirkuh. According to this treaty: a- Both the Crusaders and Shirkuh should leave Egypt to the Egyptians. b- Alexandria was to surrender to Shawar. c- Prisoners were to be exchanged. d- Shirkuh returned with his tired army to Damascus.
When the Seljuks pressed the Crusaders in Palestine, the Crusaders found that it is better to invade Egypt to increase their power. Therefore, the King of Jerusalem entered Egypt for the third time, as an enemy not as a friend. When he arrived at Bilbys, he mercilessly killed a large number of people. After that, he went to Fustat, but Shawar burnt Fustat to prevent the Crusaders from taking it as their camp. The fire lasted for 54 days. At that time, the Fatimid young Caliph, El-Adid, wrote a letter to Nur-ed-Din, asking him to come to rescue Egypt. Moreover, attached with the letter, El-Adid sent some of his wives' hair as a strong sign of supplication. When the letter reached Nur-ed-Din, he prepared the third expedition, headed by Shirkuh and supported by Saladin. When Shirkuh arrived in Egypt, he defeated the Crusaders and dismissed them. Then, the Caliph El-Adid appointed Shirkuh his vizier after Shawar had been killed because of his treason. Then, the Caliph gave Shirkuh the title of El-Malik-el-Nasr. Shirkuh stayed two months in his position till he died suddenly. Following Shirkuh was his nephew, Saladin. Two years later, Saladin got rid of the Fatimids completely founding the Ayyubid Dynasty.

Saladin (1169-1193) 

Although the reign of Saladin was short, it is considered a great period in the Muslim history in Egypt. Born in 1137-1138, Saladin was the son of Ayyub, a Kurdish officer in the court of the Baghdad Caliphate, and later, Governor of Damascus. For 10 years in the court of Nur-ed-Din, Saladin played no prominent role. He accompanied the three expeditions to Egypt and he became famous after the Battle of Baban and his defense of Alexandria. After the death of his uncle, Shirkuh, he was appointed the Vizier of the Fatimid Caliph; because the Fatimids believed that they could bring him under their control if necessary. The positions Saladin assumed were very peculiar. He was the Prime Minister of the Shiite Fatimid Caliph while he was Lieutenant (an officer) of the Sunni King. His main aim behind this was to win the loyalty of the people and to strengthen himself against his King Nur-Ed-Din, King of Syria. Moreover, he prepared the way to cancel the Shiite Caliphate and the foundation of an independent dynasty in Egypt. After two years of his reign, the Fatimid Dynasty came to an end and Egypt was ruled directly by Nur-Ed-Din, but the real authority was in the hands of Saladin. Saladin had to face many difficulties such as the revolts led by Sudanese soldiers. Succeeding in defeated those soldiers, he arrested their chief leader. Then, he sent an expedition to Sudan under the leadership of his brother, Turanshah, who conquered it and succeeded in putting an end to the revolts there. After the death of El-Adid, Saladin took the throne of Egypt and kept the Fatimids in the royal palace treating them very nicely to keep them away from the throne. Therefore, a revolt led by a poet called Omara El-Yamani (who wanted to regain the throne of the Fatimids) broke out. He gave Saladin the title of 'The Young Mameluke'. However, he was able to group the Sudanese and Turkmen soldiers against Saladin. He also persuaded the king of Cyprus and the King of Jerusalem to send their troops to invade Egypt. The King of Cyprus sent 282 ships which attacked Alexandria. However, the Ayyubid garrison in Alexandria succeeded in defeating the troops of Cyprus, until they escaped to their ships.
When the King of Jerusalem knew about the defeating of Cyprus troops, he decided not to send his army. Saladin knew the news of the revolt in Cairo from one of his spies and he arrested everyone who participated in the revolt. At the end, Omara-El-Yamani was killed and some of his followers were sent to Upper Egypt. Saladin had to face a third revolt led by a man called Kenz-Ed-Dawlah in Aswan and Qoos. Kenz-Ed-Dawlah went to Aswan and gathered some of the Sudanese soldiers and supporters of the Fatimids and he wrongly thought that he would defeat Saladin. But Saladin defeated him. At first, Saladin was very loyal to Nur-Ed-Din and he put the name of Nur-Ed-Din on the coins, under the name of the Abbassid Caliph mentioning his name in Friday orations. But when Saladin refused to help Nur-Ed-Din in his wars against the Crusaders-Seljuks and the Arabs, Nur-Ed-Din started to hate Saladin. Besides, Nur-Ed-Din was against Saladin's ambition to make Egypt an independent country under his control. Nur-Ed-Din was afraid of the increasing authority of Saladin between the Arab countries, but soon he died and Saladin became the sole ruler of Muslims. Later, Saladin worked on strengthening his position in Egypt. Then, he sent his army to invade Africa and the African Sea from Barca to Crete fell under his control in 1172. Saladin's elder brother, Turanshah, followed the blacks into Nubia and took the city of Abrim. After the Sudan expedition, Saladin sent his brother from Nubia to conquer Yemen which also fell completely under his family's rule for 55 years. After the death of Nur-Ed-Din, Saladin became the leader of the Muslims in the Near East, but with two competitors to face: 1- El-Malik-Es-Saleh (the son of Nur-Ed-Din) who was a child king. 2- Seyf-Ed-Din (the nephew of Nur-Ed-Din) who was the Prime of Mosul and Chief of the Family of Zengi. At first, Saladin started with the child King who was in the hands of bad emirs who were making relations with the Crusaders. So, going with 700 horsemen to Damascus, he invaded it and passed through Emsa. Then, he achieved a great victory at Horns of Hama against the two enemies: El-Malik-Es-Saleh and Seyf-Ed-Din. Then, he followed his enemy until the Gates of Aleppo and achieved a second victory over Seyf-Ed-Din, at an area called Mesopotamians.
A peace treaty was signed between Saladin and the young King of Aleppo, Malik-Es-Saleh. According to it, "Saladin had the full control over the countries which he had invaded, from Egypt to Euphrates". After the death of Malik-Es-Saleh, the Mesopotamian princes made a treaty with the Crusaders, so Saladin went to Mesopotamia and entered the whole country except El-Mosul. After being surrendered, Mosul accepted to be under the control of Saladin. According to a new treaty, the Northern Mesopotamian and a part of Kurdistan became under the full control of Saladin. "Now, Saladin unified all the Muslims and became the most powerful Muslim leader, who could fight the Crusaders". 
Before his death, Saladin divided his kingdom among his sons and brothers. The kingdom was divided into smaller kingdoms at Damascus, Aleppo, Homs, Hamat, and Diyar Bakr (in the actual Kurdistan, where Saladin was born). The Most important kingdom was in Egypt, where Al-Aziz Othman (Saladin's son) succeeded him in 1193, and it effectively controlled the rest of the kingdoms. Othman allied with his uncle, Al-Adil, against Saladin's other sons. Finally Al-Adil took power in 1200.

Al-Adil 

Al-Adil's troops defeated the advance of the crusaders from Damietta to Cairo by flooding the Nile, which forced then to evacuate Egypt in 1221. Al-Adil died in Syria upon hearing the news of the crusaders' seizure of the Chain Bridge (Burj al-Silsila) at Damietta in 1218.

Al-Kamil 

Al-Kamil (Al-Adil's son and Saladin’s nephew) succeeded his father. He was the one to drive back the Fifth Crusade. But the Sixth Crusade and the struggles in Damascus forced him to sign a peace treaty with them, according to which he left various cities in Palestine and Syria to Frederick II, Holy Roman Emperor.

Najm al-Din Ayyub 

Najm al-Din Ayyub, the son of Sultan Al-Kamil, ascended to the throne in 1240. He recaptured Jerusalem in 1244. Najm increased the size of his Mameluke army to face the Seventh Crusade led by Louis IX of France and the competition of the Ayyubids in Syria. In 1249, Damietta fell in the hand of Louis IX and Najm al-Din died. His wife Shajart al-Durr and his son Turanshah with his generals of Mameluke soldiers defeated Louis IX and expelled the Crusaders from Egypt. But, later,unrest struck the Ayyubid State due to the struggle of both Turanshah and Shajart al-Durr over power. Together with Izz al-Din Aybak, she schemed against Toran, who was eventually killed by the Mamelukes of his late father. Thus, with the help and support of the Mamelukes, she seized the throne, becoming the Sultana of Egypt and married Aybak who, given the royal name 'al-Malik al-Muizz', became the new Sultan of Egypt. Thus, the Ayyubids lost control over the country and the Mamluk State had risen.

Egypt under the Ayyubid Rule 

Saladin was the sole ruler and he was helped by viziers, his brothers, sons and his relatives, such as El-Adil, Bahaa-Ed-Din, El-Kadi and Emad-Ed-Din. His successors followed the same policy of Saladin in running the affairs of the country. The reigns of the Ayyubid Kings were famous for Justice, kindness, tolerance and protecting the Muslims from dangers, especially from the Crusaders. The revenue of Egypt was used to stand against the Crusaders' large fleets and armies. A large fleet and army were also built. Saladin made a separate department for the fleet, called 'Diwan-El-Ostool', which became very strong.
The Ayyubids fortified Cairo by the famous Citadel, which was built by Saladin and completed by his nephew El-Kamil, 30 years later. Saladin built it on the Mokattam Hills to be the center of the government and the fortress of his soldiers and to protect them from the Fatimids' revolts and from the Crusaders. Saladin and his successors fortified the northern ports, especially Damietta, to protect Egypt from the attacks of Crusaders. A large number of hospitals, schools, pharmacies, mosques and mausoleums witnessed the glory of the architecture of the Ayyubid Period.
Before the Ayyubid Dynasty, there were no private schools, but there were lectures that could be all ended in the old Mosque of Amr Ibn Al-Aas and the Mosque of El-Azhar. Saladin brought Sunni scholars to teach the Sunni Creeds (which are Hanafi, Shaf'i, Maleki and Hanbaliand) and he tried to destroy the Shiite Creed. Thus, he built religious colleges in Cairo and Alexandria and El-Azhar was turned into a university. Each college had its own special professors according to its creed. There were very famous scholars at that time such as Ibn-El-Athir, Bahaa-Ed-Din Zohair (poet), Sharaf-Ed-Din, etc.
Industry continued progressing as it was earlier during the Fatimids. War industry and fleet equipments witnessed a high progress because of the needs to face the Crusaders. Trade was developed during the Ayyubids, who built a big number of boats to carry goods to Venice and Genoa and Egypt made trade treaties with many countries. The traditional trade and pilgrimage route was threatened by the Crusaders, but after the great victory of Saladin over them, the route became secure and safe. The ports of Alexandria and Damietta were full of boats coming from Italy, Syria, Greece and Cyprus. The Venetian boats used to transport some goods from the East to Europe, among which were the Syrian textiles, flax, precious stones and spices.
The Feudal System became weak and the farmers took the freedom to gain from their work. The government helped the farmer by digging canals and building bridges. As a consequence, this increased the revenue of the Treasury. But During the time of Sultan El-Adil, the level of the Nile decreased and a famine happened.

Conditions of Egypt under the Ayyubids

 

 Saladin was the sole ruler and he was helped by viziers, his brothers, sons and his relatives, such as El-Adil, Bahaa-Ed-Din, El-Kadi and Emad-Ed-Din. His successors followed the same policy of Saladin in running the affairs of the country. The reigns of the Ayyubid Kings were famous for Justice, kindness, tolerance and protecting the Muslims from dangers, especially from the Crusaders. The revenue of Egypt was used to stand against the Crusaders' large fleets and armies. A large fleet and army were also built. Saladin made a separate department for the fleet, called 'Diwan-El-Ostool', which became very strong.

The Feudal System became weak and the farmers took the freedom to gain from their work. The government helped the farmer by digging canals and building bridges. As a consequence, this increased the revenue of the Treasury. But During the time of Sultan El-Adil, the level of the Nile decreased and a famine happened. Industry continued progressing as it was earlier during the Fatimids. War industry and fleet equipments witnessed a high progress because of the needs to face the Crusaders. Trade was developed during the Ayyubids, who built a big number of boats to carry goods to Venice and Genoa and Egypt made trade treaties with many countries. The traditional trade and pilgrimage route was threatened by the Crusaders, but after the great victory of Saladin over them, the route became secure and safe. The ports of Alexandria and Damietta were full of boats coming from Italy, Syria, Greece and Cyprus. The Venetian boats used to transport some goods from the East to Europe, among which were the Syrian textiles, flax, precious stones and spices.

The Ayyubids fortified Cairo by the famous Citadel, which was built by Saladin and completed by his nephew El-Kamil, 30 years later. Saladin built it on the Mokattam Hills to be the center of the government and the fortress of his soldiers and to protect them from the Fatimids' revolts and from the Crusaders. Saladin and his successors fortified the northern ports, especially Damietta, to protect Egypt from the attacks of Crusaders. A large number of hospitals, schools, pharmacies, mosques and mausoleums witnessed the glory of the architecture of the Ayyubid Period.

 

Before the Ayyubid Dynasty, there were no private schools, but there were lectures that could be all ended in the old Mosque of Amr Ibn Al-Aas and the Mosque of El-Azhar. Saladin brought Sunni scholars to teach the Sunni Creeds (which are Hanafi, Shaf'i, Maleki and Hanbaliand) and he tried to destroy the Shiite Creed. Thus, he built religious colleges in Cairo and Alexandria and El-Azhar was turned into a university. Each college had its own special professors according to its creed. There were very famous scholars at that time such as Ibn-El-Athir, Bahaa-Ed-Din Zohair (poet), Sharaf-Ed-Din, etc.