His posting there saw Britain invade and occupy Egypt, then technically part of the Ottoman Empire, under the pretext of "restoring law and order" following anti-foreign riots in Alexandria which had left nearly 50 foreigners dead, and Dufferin was heavily involved in the events surrounding the occupation. Dufferin managed to ensure that the Ottoman Empire did not attain a military foothold in Egypt, and placated the population of Egypt by preventing the execution of Urabi Pasha, who had seized control of the Egyptian army. Urabi had led the resistance to foreign influence in Egypt, and after the occupation many in the Cabinet were keen to see him hanged. Dufferin, believing this would only inspire further resistance, instead ensured that Urabi was exiled to Ceylon.