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.
Accompanying Andrade as adjutant general of the army of the north on their march on Porto-Lisbon, Pereira was made secretary of the Regency, after the Convention of Sintra, and was given the war and foreign affairs portfolios.
[2] In this capacity he took part in the reorganisation of the army under William Carr Beresford (who had been appointed commander-in-chief by the Portuguese Royal family), completing the implementation of the 1803 proposals in 1807.
In 1826 he received the title of Count of Feira and was elected a Peer of the Kingdom on the occasion of the giving of the Constitutional Charter by Peter IV of Portugal.