In conquering Egypt during the closing years of the 18th century, Napoleon hoped to secure a base from which he could embark on the conquest of Britain's lucrative possessions in India.
In 1798, Napoleon's fleet set sail for Egypt stopping to capture and plunder the prosperous Mediterannean island of Malta ending centuries of rule of the island by the soldier-monks known as the Knights of Malta. Despite rough weather making the landing of his army of over 30,000 men a dangerous affair, Napoleon took Alexandria which had shrunk to a population of only about 6,000 with, as he had suspected, little opposition. Nelson was hoping to intercept and engage the French fleet in the Mediterannean, but missed sighting them despite their close proximity before it arrived off the Egyptian coast.
Napoleon made his way inland routing the Mamelukes at the Battle of the Pyramids and capturing Cairo but Nelson had sighted the French fleet anchored of the Egyptian coast and destoryed it in the Battle of the Nile. The French commander of the fleet had about a third of his men ashore obtaining supplies, the British fleet was sighted late in the day and the French erroneously assumed that there would not be an attack during the night.
Nelson's victory over the French fleet cut Napoleon off in Egypt.
In 1799, Bonaparte invaded Syria to fight a Turkish army whose object was to recapture Egypt. He failed to take Acre which was defended by the Turks and Sir Sidney Smith and returned to Egypt to defeat the Turks at Aboukir.
Bonaparte left Egypt on August 22nd, 1799, sailing from Alexandria having left Kl�ber in command of his Egyptian army.