He participated in the defense of the Viceroyalty of the Río de la Plata against British invasions of the River Plate between 1806 and 1807 and helped to expel British from Montevideo, which they had occupied in 1807.