After securing the loyalty of the northwestern Provinces to the May Revolution through elections of representatives to the Junta in Buenos Aires, Castelli sent General Antonio González Balcarce into the Upper Peru, but he was defeated at the battle of Cotagaita. Castelli then sent him reinforcements, leading to the first patriotic victory at the battle of Suipacha, which gave Buenos Aires control over the Upper Peru. The royalist generals Vicente Nieto, Francisco de Paula Sanz and José de Córdoba y Rojas were captured and executed.