Appointed Brigade Major to Brigadier-General Thomas Graham, Hamilton was present at the Siege of Malta then joined the Expedition to Egypt under Lieutenant-General Sir Ralph Abercromby. While in Egypt he was thanked by Lieutenant-General Sir John Doyle in public orders for his conduct in the engagements of the 13 and 21 March and 17August 1801. Hamilton then commanded several light infantry battalions in Ireland before his regiment joined Wellington's army in Portugal. He was present at the Siege of Cádiz during the Peninsular War, commanded the battalion at the 1811 Battle of Fuentes de Oñoro and after promotion to Lieutenant Colonel, again commanded his battalion at the Battle of Salamanca the following year.