Civil war broke out between the provinces of Venezuela that recognized the Caracas Junta and those that still recognized the Regency in Spain (the Cortes of Cádiz), that had replaced the Supreme Central Junta. The situation became more tense when a congress, called by the Caracas Junta, declared independence on July 5, 1811, sparking rebellions in Valencia in favor of the Cortes of Cádiz. Bolívar's first military service was as an officer under Miranda's command in the units created to put down this revolt. Bolívar was promoted to colonel and made commandant of Puerto Cabello the following year. At the same time that Frigate Captain Domingo de Monteverde was making fast and vast advances into republican territory from the west (his forces had entered Valencia on May 3, 1812), Bolívar lost control of San Felipe Castle along with its ammunition stores on June 30, when the royalist prisoners held there managed to take it over and attack the small number of troops in the city. Deciding that the situation was lost, Bolívar effectively abandoned his post and retreated to his estate farm in San Mateo. Miranda also saw the republican cause as lost and authorized a capitulation with Monteverde on July 25.