Álvarez was born in Granada. He joined the army in 1768 (aged 19), and studied at the Military Academy of Barcelona, graduating in 1775. He gained steady promotions, saw action in the siege of Gibraltar in 1783, and by 1793 was a Colonel of Infantry. During the War of the Pyrenees (1793–1795) against France he took part in many notable actions, was wounded, and spent 75 days under fire at the siege of Collioure. As a result, he was promoted to Brigadier.