In August 1845, Magruder volunteered for assignment in Corpus Christi, Texas, to join General Zachary Taylor's army there, occupying the former republic; the US was on the verge of war with Mexico over the question of annexation. After hostilities opened on April 25, 1846, Magruder first saw combat at the Battle of Palo Alto, 14 days later. On April 18, 1847, Magruder served with "zeal and ability", in General Winfield Scott's expedition, under heavy fire and turned Mexican artillery against them at Cerro Gordo, for which he was praised by his superiors and brevetted to major. By September 12, US forces had begun targeting Chapultepec, in one of a series of engagements in the Battle of Mexico City. Magruder—lightly wounded—ordered the first shots in the early morning on the 13th and offered pursuit, despite superior Mexican numbers, to capture the Anzures, Veronica, and Belen intersection—a crucial crossroads that would block efforts by General Santa Anna to relieve the palace.