He soon obtained a command in the Portuguese artillery, and as a lieutenant colonel of the Portuguese service took part in the various battles of 1810–11. At the sieges of Ciudad Rodrigo, Badajoz, the Salamanca forts, and Burgos, he was entrusted by Wellington with most of the detailed artillery work. At the Battle of Salamanca he commanded the reserve artillery. In the end he became commander of the whole of the artillery of the allied army, and though still only a substantive captain in the British service, he had under his orders some 8000 men. He played a key role in the successful conclusion of the Siege of San Sebastián in 1813. At the battles of Vitoria, the Pyrenees and Toulouse he directed the movements of the artillery engaged, and at the end of the war received handsome presents from the officers who had served under him, many of whom were his seniors in the army list.