San Martín took part in the combat of Arjonilla, being promoted to First Captain for his brave actions. In the battle, a French officer nearly killed him with his sword, but he was saved by Sargeant Juan de Dios, who died in the effort. The following July 19 he took part in the Battle of Bailén, where 14,000 Spanish defeated 10,000 French. San Martín was promoted to lieutenant colonel, and his prestige continued to rise. This victory gave new hopes to the Spanish front, forcing Joseph Bonaparte to leave Madrid and allowing later the liberation of Andalucía. However, San Martín is forced to take a license, because of a pulmonary affection.