 In 1841, Scott became the Commanding General of the United States Army, beating out his rival, Edmund P. Gaines, for the position.After the outbreak of the Mexican–American War in 1846, Scott initially served as an administrator, but in 1847 he led a campaign against the Mexican capital of Mexico City.After capturing the port city of Veracruz, he defeated Mexican General Antonio López de Santa Anna's armies at the Battle of Cerro Gordo, the Battle of Contreras, and the Battle of Churubusco and captured Mexico City.