This meant that Scott was commander during the Mexican War. Initially, he recommended General Zachary Taylor to command in the field, and Taylor won a series of victories in 1846, but his campaign was confined to northern Mexico, and Scott felt that little progress was being made towards final victory. Towards the end of 1846, Scott suggested an amphibious invasion of central Mexico, with the aim of taking Mexico City itself. However, now politics intervened. President Polk, a democrat, did not want Scott, a Whig, to get the glory of such a successfull campaign, and instead suggested that Taylor march across the desert instead, and only agreed to Scott's plan when Taylor vetoed the overland plan. Scott prepared his force at Tampico (January-March 1847), where he massed 10,000 men, including most of Taylor's regular troops, and on 9 March 1847 his fleet arrived near the Mexican city of Veracruz, east of Mexico City. They were allowed to land unopposed, and after a five day siege took the city, and immediately moved away from the coast to avoid Yellow Fever. The Mexican defense was directly commanded by Santa Anna, who moved to block the US march at Cerro Gordo, a fortified valley on the road inland. Santa Anna had 12,000 men to Scott's 8,500, but Scott found unmarked mountain paths, and was able to surround Santa Anna's force, winning the battle of Cerro Gordo (18 April 1847), and routing Santa Anna's army, which lost a third of it's numbers. A month later, on 15 May, Scott reached Puebla, seventy five miles east of Mexico City, where he was forced to stop, 4,000 of his men having returned home at the end of their period of service. He was not able to move again until his force had been rebuilt, and was forced to wait at Puebla until August, when he could muster 11,000 men. On 7 August, he took a bold gamble, marching on Mexico City with almost his entire army, leaving a small garrison at Puebla, and isolating his army from the outside world. Facing him, Santa Anna had 30,000 men defending Mexico City. The main road to the city passed to the north of Lake Chalco and Lake Xochimilco, but Scott found that path to be blocked, and detoured south of the lakes. However, when he approached Mexico City, he still found strong forces facing him, in particular at Contreras and Churubusco. On 20 August, Scott launched attacks on both positions (battle of Contreras and battle of Churusbusco), taking both positions and inflicting heavy casualties on the Mexicans, who nevertheless still outnumbered him. Two weeks of peace negotiations followed, but failed. Scott now found himself facing two last obstacles before the city. First was 12,000 Mexican troops at Molino del Rey in an old fort, which Scott captured on 8 September (battle of Molino del Rey). Finally, he was faced by another strong Mexican force on the fortified hill of Chapultepec. After a preliminary bombardment (12 September), Scott took the hill by storm (battle of Chapultepec), once again inflicting heavy losses on the Mexicans. At this point Santa Anna realised that the war was lost, and withdrew his troops from Mexico City, and on 14 September, Scott was able to march in unopposed, effectively ending the war. Once again politics intervened, and Scott was recalled to Washington to face trumped up charges. To Polk's embarrassment, Scott received a hero's welcome, and a gold medal from Congress, which Polk had to present him with, while the charges were soon dropped.
Polk's fear of Scott's political ambitions were not ungrounded. In 1852 Scott was the Whig candidate for the presidency, but was defeated, in part because the Whig's were split over slavery. However, Scott's army career continued uninterrupted. In 1855 he became the first man since Washington to be promoted to Lieutenant General. He was still commander of the army as the American Civil War approached. In 1860 he suggested reinforcing federal garrisons in the south, in case of rebellion. When war came, Scott suggested a naval blockade of the South, combined with the raising of a 300,000 strong army to march down the Mississippi to the Gulf of Mexico, with the aim of isolating the Confederacy. Although similar to the plan eventually followed, this was dismissed because it did not promise quick results, and late in 1861 Scott retired, to be replaced by George McClellan. While the war continued, Scott visited Europe and wrote his memoirs. He survived to see the end of the war, dying at West Point on 29 May 1866, where he is buried.