Since the days of Godfrey and Baldwin I., Egypt had been a goal of Latin ambition, and the capture of Ascalon must obviously have given form and strength to the projects for its conquest. Plans of attack were sketched: routes were traced: distances were measured; and finally in 1163 there came the impulse from within which turned these plans into action. The Shiite caliphs of Egypt were by this time the playthings of contending viziers, as the Sunnite caliphs of Bagdad had long been the puppets of Turkish sultans or amirs; and in 1164 Amalric I. and Nureddin were fighting in Egypt in support of two rival viziers, Dirgham and Shawar. For Nureddin the fight meant the acquisition of an heretical country for the true faith of the Sunnite, and the final enveloping of the Latin kingdom:[35] for Amalric it meant the escape from Nureddin's net, and a more direct and lucrative contact with Eastern trade. Into the vicissitudes of the fight it is not necessary here to enter; but in the issue Nureddin won, in spite of the support which Manuel gave to Amalric. Nureddin's Kurdish lieutenant, Shirguh, succeeded in establishing in power the vizier whom he favoured, and finally in becoming vizier himself (January 1169); and when he died, his nephew Saladin (Sala-ed-din) succeeded to his position (March 1169), and made himself, on the death of the caliph in 1171, sole ruler in Egypt. Thus the Shiite caliphate became extinct: in the mosques of Cairo the name of the caliph of Bagdad was now used; and the long-disunited Mahommedans at last faced the Christians as a solid body. But nevertheless the kingdom of Jerusalem continued almost unmenaced, and practically undiminished, for the next sixteen years. If a religious union had been effected between Egypt and northern Syria, political disunion still remained; and the Franks were safe as long as it lasted. Saladin acted as the peer of Nureddin rather than as his subject; and the jealousy between the two kept both inactive till the death of Nureddin in 1174. Nureddin only left a minor in his place: Amalric, who died in the same year, left a son (Baldwin IV.) who was not only a minor but also a leper; and thus the stage seemed cleared for Saladin. He was confronted, however, by Raymund, count of Tripoli, the one man of ability among the decadent Franks, who acted as guardian of the kingdom; while he was also occupied in trying to win for himself the Syrian possessions of Nureddin. The task engaged his attention for nine years. Damascus he acquired as early as 1174; but Raymund supported the heir of Nureddin in his capital at Aleppo, and it was not until 1183 that Saladin entered the city, and finally brought Egypt and northern Syria under a single rule.