When the Spanish monarchy resumed its functions in 1814, Spain was determined to recover control over its colonies in the Americas. Moreover, the royalists from Peru had been victorious at the battles of Sipe-Sipe, Huaqui, Vilcapugio and Ayohuma, in Upper Peru, and seriously threatened the United Provinces from the north.