On 31 January 1830, the Polignac government decided to send a military expedition to Algeria to put an end to the threat the Algerian pirates posed to Mediterranean trade and also increase the government's popularity with a military victory. The reason given for the war was that the Viceroy of Algeria, angry about French failure to pay debts stemming from Napoleon's invasion of Egypt, had struck the French consul with the handle of his fly swat. French troops occupied Algiers on 5 July.