In 1787 he was accepted into the Irish Brigade of the Spanish army, and joined the army fighting in Ceuta in northern Africa, under Lieutenant Colonel Luis Urbina, and was promoted to Second Lieutenant. In 1791 Mackenna resumed his studies in Barcelona and acted as liaison with mercenaries recruited in Europe. The following year he was promoted to Lieutenant in the Royal Regiment of Engineers. In the War of the Pyrenees against the French, Juan Mackenna fought in Rosselló under General Ricardos and there met the future liberator of Argentina, José de San Martín. For his exploits in defence of the Plaza de Rozas, he was promoted to captain in 1795.