In 1840 and 1841 there were several related rebellions against Anastasio Bustamante, then in his third period as president of Mexico. Bustamante was an adherent of the centralist party. On July 15, 1840, soldiers led by rebellious General José Urrea and Valentín Gómez Farías took the presidential palace and captured President Bustamante, later releasing him. The chief of the general staff, General Gabriel Valencia, helped subdue the revolt. Shortly thereafter, Mariano Paredes y Arrillaga rose against Bustamante in Guadalajara, Juan N. Álvarez in the south, and López de Santa Anna in Perote, Veracruz. This time, on September 4, 1841, Valencia joined the rebellion by publishing the Plan de la Ciudadela. The situation was now serious for Bustamante, himself a general. He took the field to fight the rebels, but was defeated. Bustamante went into exile in Europe for a second time. The generals arrayed against him then reached a political agreement proclaimed as the Plan de Tacubaya. This plan proclaimed the presidency vacant and named a provisional president to call elections for a constituent congress. This provisional president was, once again, López de Santa Anna. This was his sixth term as president.
Overthrow of President Herrera, 1845
After several other changes in the office of president, José Joaquín de Herrera became interim president on December 17, 1844. He became constitutional president on September 16, 1845. Two days before, General Mariano Paredes y Arrillaga again revolted, in opposition to Herrera. In December 1845 Herrera announced he was setting out at the head of an expedition to repel North American invaders, who had reached Saltillo. General Paredes used this opportunity to seize power. On December 30, 1845, General Valencia, now in charge of the garrison of Mexico City, announced his support for Paredes. Out of options, Herrera turned power over to Valencia.
As interim president of Mexico
By operation of law, Gabriel Valencia, as chairman of the Governing Council is who should assume the presidency following the resignation of President Jose Joaquin de Herrera. This was a temporary appointment, meant only to serve the transfer of power. A junta, led by the archbishop of Mexico City, Manuel Posada, was convoked. On January 2, 1846 this junta elected General Paredes interim president. Valencia's term had lasted three days.
In 1847 General Valencia was among the Mexican forces opposing General Winfield Scott's advance from Veracruz to Mexico City in the Mexican–American War. On August 19, 1847, Scott's forces attacked those of Valencia in the town of Contreras, near Mexico City. Because of rivalry between Valencia and López de Santa Anna, Valencia had advanced beyond his assigned position. Santa Anna could not send reinforcements. The Mexicans were badly defeated on August 20. The remnants of Valencia's forces fell back to Churubusco, joining Santa Anna's forces there. Scott continued his advance, and the Mexicans were defeated again at Chapultepec, leaving the way open to Mexico City, that finally was occupied on September 16.