Stevens was the adjutant of the Corps of Engineers during the Mexican–American War, seeing action at the siege of Vera Cruz and at Cerro Gordo, Contreras, and Churubusco. In the latter fight, he caught the attention of his superiors, who rewarded him with the brevet rank of captain. He was again cited and breveted for gallantry at the Battle of Chapultepec, this time to the rank of major. Stevens participated in combat at Molino del Rey, and the Battle for Mexico City, where he was severely wounded. He later wrote a book on his adventures, "Campaigns of the Rio Grande and Mexico, with Notices of the Recent Work of Major Ripley" (New York, 1851).