Upon graduating from West Point, Lyon was commissioned as a 2nd lieutenant and assigned to the 2nd U.S. Infantry Regiment after graduation and served with them in the Seminole Wars and the Mexican–American War. Despite denouncing American involvement in the Mexican War, he was promoted to first lieutenant for "conspicuous bravery in capturing enemy artillery" at the Battle for Mexico City and received a brevet promotion to captain for the battles of Contreras and Churubusco. Although he was eligible for membership, Lyon did not join the Aztec Club of 1847 when it was formed in Mexico City in 1847.