He was a candidate for president of the republic in 1828 in opposition to Vicente Guerrero and actually won the election. However, on 3 December 1828, under military threat by his adversaries, including Antonio López de Santa Anna, he "renounced" his victory and left the country. The election was annulled, and under the :es:Plan de Perote|Plan de Perote, Vicente Guerrero assumed the presidency. He returned to Veracruz in October 1830 from Bordeaux, France, but was immediately sent back into exile by his enemies. He then went to New Orleans, where he published a manifesto against the government of Anastasio Bustamante.
President at last
Gómez Pedraza returned to Mexico on 5 November 1832. The :es:Plan de Zavaleta|Plan de Zavaleta recognized him as president, and he took office on 24 December 1832 in Puebla. He entered Mexico City on 3 January 1833 accompanied by Santa Anna. One of his first official acts was to enforce a decree of 22 February 1832 that expelled the remaining Spanish citizens from the country. Soon after being named president, he convoked the Congress, which, however, elected Santa Anna president and Valentín Gómez Farías vice-president. Because of the former's illness, Gómez Farías took office as president, on 1 April 1833, replacing Gómez Pedraza.
Later years
In 1841, Gómez Pedraza was named to Santa Anna's cabinet as minister of internal and external affairs. Also in 1841, he was a deputy to the constituent congress, and was detained when that congress was dissolved. As a federal deputy beginning in 1844, he was known for his eloquent orations. That year he spoke in the Senate against the personal dictatorship of Santa Anna. In 1846, he became a member of the Council of Government, and the following year he returned as minister of relations, when the government was transferred to Querétaro because of the U.S. occupation of Mexico City. He was president of the Mexican Senate during the debate and approval of the Treaty of Guadalupe-Hidalgo that ended the war. His speech to the Senate on 24 May 1848 about the war with the United States has been described as "one of the most brilliant pieces of oratory in the history of the Mexican Parliament." In 1850, he ran again for president, but was defeated by General Mariano Arista. He was director of the Nacional Monte de Piedad when he died in Mexico City in 1851, refusing the last rites. The clergy did not allow his burial in sacred ground.