Nur ad-Din's three campaigns in Egypt in 1164-69 led to the overthrow of the Shi'a Fatimid dynasty, the restoration of orthodox Sunni rule in Egypt, and played a major part in the rise of Saladin.
In the mid twelfth century the Islamic world was split between two caliphates. The orthodox Sunni Abbasid caliphs had seized power in 750. They were descended from the Prophet Mohammed's youngest uncle, Abbas ibn 'Abd al-Muttalib. The Abbasid caliphs eventually lost most of their political power to the Seljuk Turks, who ruled as Sultans, but by the twelfth century the Seljuk Empire had fractured and the various major cities were effectively independent. Nur ad-Din was one of the most important Seljuk rulers to emerge during this period. His father Zengi had been a Seljuk governor of Mosul who captured Aleppo from a rival line of emirs and took Edessa from the Crusaders. Nur ad-Din inherited Aleppo and Edessa, and later captured Damascus.
The second caliphate was the Shi'a Fatimid caliphate. This had once ruled a vast area from northern Africa to the coast of Syria, but by the twelve century the Fatimids only controlled Egypt. They claimed descent from the Prophet's daughter Fatima. By the twelfth century the Fatimid caliphs had also lost most of their power and Egypt was ruled by a series of viziers, normally military hard-men who gained power by defeated the previous caliph. Although Nur ad-Din gained his first major victory against the Crusaders at Edessa, his main focus seems to have been the destruction of the Fatimid caliphate and the reunification of the Islamic world.
All of Nur ad-Din's campaigns in Egypt had one thing in common - he never took part in person, but instead the command was held by Shirkuh, the uncle of Saladin. All three also involved Shawar, sometimes the vizier of Egypt, and Amalric, king of the crusader kingdom of Jerusalem.
In 1163 Shawar was deposed as vizier, and fled to Damascus where he attempted to convince Nur ad-Din to send an army to restore him to power. At first Nur ad-Din was unconvinced, but late in 1163 Amalric began a siege of the fortress city of Bilbais, on the eastern edge of the southern part of the Nile delta.
Nur ad-Din's army was commanded by Shirkuh. We don’t know if Saladin took part in the expedition. Shawar's rival Dirgam was defeated at Bilbais, and killed by the Cairo mob. Shawar was restored to power in May 1164, but he then attempted to double-cross the Syrians. Shirkuh's men weren't allowed within the walls of Cairo, and he refused to pay the promised tribute. On 18 July the Syrians, with Bedouin allies, defeated the Egyptians outside Cairo. Shawar escaped when the caliph used the palace guard to rescue him.
Shawar then asked for help from the kingdom of Jerusalem. This appealed to Amalric, who didn't want to be surrounded by Nur ad-Din's kingdoms. The Crusaders and their Egyptian allies besieged Shirkuh in Bilbais (August-October 1164), and total victory seemed near.
Shirkuh was saved by Nur ad-Din, who led an invasion of the Crusader holdings in northern Syria. He besieged Harim and inflicted a heavy defeat on the Crusaders in a battle at the same place. Several senior crusader leaders were captured, but Nur ad-Din didn’t want to risk dragging the powerful Byzantines into the area and didn't press his advantage.
Nur ad-Din's victory meant that Amalric needed to return to his kingdom. He negotiated peace terms with Shirkuh, and both of their armies returned home. Shawar was left in power in Egypt.
On his return to Syria Shirkuh reported that Egypt was vulnerable to conquest, with a Sunni population and a weak Shi'a government. He gained the support of the caliph at Baghdad, who pressured Nur ad-Din to act. Eventually Nur ad-Din was won over and in January 1167 he dispatched Shirkuh and a bigger army of Kurds, Turks and Bedouin into Egypt, this time with the single task of removing the Fatimid caliph. This time Saladin was present, and would play a fairly major part in the campaign.
Amalric realised that this move posed a real threat to the Crusader kingdoms. He held a meeting a meeting of the barons of the kingdom of Jerusalem at Nablus, and convinced them to mobilise. Some would stay at home to defend against any attack by Nur ad-Din, while Amalric and the main army moved into Egypt, where they would ally with Shawar.
Shirkuh led his army across Sinai, taking a route designed to avoid the Crusaders. His army ran into a deadly sandstorm that inflicted some casualties on his army. When he reached Egypt Shirkuh crossed the Nile 40 miles south of Cairo. This was probably done to put the river between him and the larger Egyptian and Crusader armies. After crossing the river he moved north and camped at Giza. He attempted to convince Shawar to join an alliance against the Franks, but Shawar refused to turn on his allies.
After a period of stalemate Amalric and the Egyptians crossed the Nile. Shirkuh retreated south for around 100 miles, but battle was eventually joined at Babain on 18 March 1167. Saladin commanded in the Syria centre and carried out a feigned retreat that pulled Amalric away from the main battle. The Crusaders managed to escape from the trap, and although Shirkuh probably won a victory, it was an inconclusive one. In the aftermath he led his army to Alexandria, where the city had risen against the Fatimids.
Amalric and the Egyptians moved to besiege Alexandria. Saladin was left in command in the besieged city, while his uncle carried out raids and attempted to recruit fresh troops. Saladin managed to hold out until his uncle returned and negotiated an end to the war. The terms of the peace were very favourable to the Franks. They were allowed to install a garrison to control the gates of Cairo, had a resident prefect in the city and were to receive double the previous annual tribute. Shirkuh was to return to Damascus. Saladin negotiated a safe conduct for his supporters in Alexandria, and then put some effort into making sure that the deal was honoured. Once again Shawar was left in control in Cairo.
Only a year later the Franks undermined their own position in Egypt. The behaviour of the Christian troops at Cairo made them increasingly unpopular. Shawar delayed the payments of the tribute in an attempt to bolster his position. Amalric came under pressure to react, and may also have been worried that the Byzantines were considering their own campaign in Egypt. He didn’t want to move so quickly, but his council forced him into action, and in October 1168 the Franks invaded Egypt.
Their first action was yet another siege of Bilbais. This time the city held out for an unexpected length of time. At the end of the siege the Franks carried out a massacre, killing both Muslims and Christian Copts. This united almost the entire Egyptian population against them. Muslim enemies of Shawar couldn't risk siding with the Franks and the Copts no longer saw them as a potential protector.
From Bilbais the Franks moved to Cairo, where they began a loose blockade. The Caliph sent a message to Nar ad-Din asking for help, and hinting that he might inherit Egypt as a reward. Nar ad-Din sent a third army, once again commanded by Shirkuh. Saladin accompanied the army, but only after originally refusing to go. The army, with Saladin, left Syria on 17 December 1168.
Shawar informed Amalric that the Syrians were approaching, in the hope that the two armies could exhaust each other. Amalric decided to withdraw from Cairo. He made a half-hearted attempt to intercept the Syrians, but then retreated back to Jerusalem.
On 9 January 1169 the Syrians under Shirkuh entered Cairo in triumph. Although they had invaded two years early in an attempt to depose the Fatimid caliph, now Shirkuh was willing to work with him. Caliph Al-Adid welcomed the Syrians, and gave official backing to the removal and execution of Shawar on 18 January 1169. Shirkuh accepted the posts of vizier and commander of the Egyptian army. He now served two masters - Nur ad-Din in Damascus and Al-Adid in Cairo. Nur ad-Din was angered by this and ordered Shirkuh to return home. When he refused he was stripped of all of his lands in Syria. We don’t know how Shirkuh would have coped with this situation, for on 23 March he died.
He was replaced as vizier and commander of the army by Saladin, who now began his rise to power. At first he worked with the Fatimid Caliph, but in 1171 Caliph Al-Adid died of natural causes. At the same time the Caliph in Baghdad was named in the prayers in Cairo, and Egypt had returned to the Sunni fold.
For several years Saladin had to treat a fine line between enjoying his authority in Egypt and keeping Nur ad-Din happy. This ended with the death of Nur ad-Din in 1174. Saladin left Egypt and moved to Damascus, ending the short but crucial Egyptian period of his life.