After Napoleon sailed back home he left Kleber in charge who was furious at Napoleon's abandonment. He did not believe that French occupation of Egypt would last long and did not see any need to colonize the country. With opposition to the French rule increasing and a Turkish army on its way from Gaza, Kebler talked directly to the Turks, offering to concede Egypt to them and to restore the Franco-Turkish alliance. After suffering another defeat at El Arish Kleber and the Grand Vizier reached an agreement, under which the Ottomans would end their alliance with Britain and Russia in exchange for a French withdrawal from Egypt. However the British government had disavowed the agreement, believing the French in Egypt to be on the brink of total defeat. So when the Turks - under the terms of the agreement - arrived in Cairo, Kebler, appalled by the British disavowal, ordered his men into the field and in a battle near Heliopolis the French routed an army four times as large. Even after this victory Kleber sought to reach an agreement with the Turks. One Turkish contingent that managed to bypass the French after Heliopolis reached Cairo, which had been left unprotected, and encouraged mobs to take the streets. Kleber was forced to bombard the city, eventually regaining control. His victory was short-lived however, as he was assassinated by an Arab fanatic soon after.
After that the British cut Alexandria off from the garrison in Cairo and the Turks re-entered Egypt from the east. General Balliard in charge of Cairo, decided to capitulate and around 13,000 French troops were permitted to evacuate Cairo and to leave for France. The forces in Alexandria held out for a few weeks longer but also sought terms soon after.
Source: The War of Wars by Robert Harvey