In 1772, Gálvez returned to Spain in the company of his uncle, José de Gálvez. Later, he was sent to Pau, France, where he served with the Royal Cantabria regiment, an elite Franco-Spanish unit, for three years. There, he learned to speak French, which served him well when he became governor of Louisiana. He was transferred to Seville in 1775, and then he participated in Alejandro O'Reilly's disastrous expedition to Algiers. Gálvez himself was seriously wounded in the line of duty when Spanish forces assaulted the fortress that guarded the city; he was later appointed a professor at the military academy of Ávila and promoted to lieutenant colonel. He was made colonel in 1776.