He entered the army in 1785, as a cadet in the Regiment of Peniche, in which he met many members of his family. In 1787 he was promoted to alferes (lieutenant) and served as chief of staff to the Count of Oeynhausen, inspector-general of the Infantry, fighting alongside him at Porcalhota in 1790. He was promoted to captain in 1791 and to major (sargento-mor) in 1793, and was made adjutant to general Forbes, commander of the Portuguese division then fighting in Roussillon and Catalonia.