After a bitter debate in Congress the Republic of Texas was voluntarily annexed in 1845, which Mexico had repeatedly warned meant war. In May 1846, Congress declared war on Mexico after Mexican troops massacred a U.S. Army detachment in a disputed unsettled area. However the homefront was polarized as Whigs opposed and Democrats supported the war. The U.S. Army, augmented by tens of thousands of volunteers, commanded by General Zachary Taylor, defeated Santa Anna's in northern Mexico while other American forces quickly took possession of New Mexico and California. Mexico continued to resist despite a chaotic political situation, and so Polk launched an invasion of the country's heartland. A new American army led by Winfield Scott occupied the port of Veracruz, and pressed inland amid bloody fighting. Santa Anna offered to cede Texas and California north of Monterey Bay, but negotiations broke down and the fighting resumed. In September 1847, Scott's army captured Mexico City. Santa Anna was forced to flee and a provisional government began the task of negotiating peace. The Treaty of Guadalupe Hidalgo was signed on February 2, 1848. It recognized the Rio Grande as the southern boundary of Texas and ceded what is now the states of California, Nevada, Utah, Colorado, Arizona, and New Mexico to the United States, while also paying Mexico $15,000,000 for the territory. In the presidential election of 1848, Zachary Taylor ran as a Whig and won easily when the Democrats split, even though he was an apolitical military man who never voted in his life. Scott became the last Whig candidate for president in 1852, and he lost badly.