In the American War of Independence (1775–1783), Hamilton fought in the Invasion of Canada and the Battle of Freeman's Farm, commanding the middle column during the latter. He was in the Convention Army, imprisoned in Cambridge, Massachusetts after its surrender following the Battles of Saratoga. While a prisoner of war, he adopted James Hamilton, the son of a non-commissioned officer in the British Army.