He served with the same battalion in the Peninsula from 1810 to 1812, and was present at the battles of Busaco and Fuentes d'Onoro in the action of Sabugal, and in those of the retreat of Massena. He accompanied the 4th battalion on the expedition under Major-general Gibbs to Stralsund in 1813, but served on the staff as a deputy assistant quartermaster-general. He also served in a similar capacity in the campaign of 1814 in Holland and Flanders, and with the head-quarters of the army of occupation in Paris. His knowledge of languages made him of use to Wellington in correspondence and negotiations with the allied powers. He was promoted major on 19 July 1821, and placed on the unattached half-pay list on 1 June 1826. His father died in Edinburgh on 17 October the same year.