Longstreet served with distinction in the Mexican–American War with the 8th U.S. Infantry. He fought under Zachary Taylor as a lieutenant in May 1846 in the battles of Palo Alto and Resaca de la Palma. He recounted both of these battles in his memoirs but wrote nothing about his personal role in them. On June 10, Longstreet was given command of Company A of the Eighth Infantry of William J. Worth's Second Division. He fought again with Taylor's army at the Battle of Monterrey in September 1846. During the battle, about 200 Mexican lancers drove back a group of American troops. Longstreet, commanding companies A and B, led a counterattack, killing or wounding almost half of the lancers. On February 23, 1847, he was promoted to the rank of first lieutenant. General-in-Chief Winfield Scott ordered Worth's division out of Taylor's army and under his direct command in order to participate in an assault on the Mexican capital of Mexico City. Worth's division was sent first to Lobos Island. From there it sailed 180 miles (289.7 km) south to the city of Veracruz. Worth led Scott's army in its amphibious approach on the city, arriving there on March 9. Scott besieged the city and subjected it to regular bombardments. It surrendered on March 29. The American army then marched north towards the capital. In August, Longstreet served in the Battle of Churubusco, a pivotal battle as the U.S. Army moved closer to capturing Mexico City. The Eighth Infantry was the only force in Worth's division to reach the Mexican earthworks. Longstreet carried the regimental banner under heavy Mexican fire. The troops found themselves stuck in a ditch and could only scale the Mexican defenses by standing on each other. In the fierce hand-to-hand combat that ensued, the Americans prevailed. Longstreet received a brevet promotion to captain for his actions at Churubusco.