Although he consistently ranked near the bottom of his class, Maxey did graduate in 1846 and was commissioned a Brevet second lieutenant. He was assigned to the 7th Infantry Regiment, which was engaged in the Mexican–American War. Maxey joined the regiment in Monterrey, Mexico. Maxey was cited for gallantry and brevetted first lieutenant for his actions in the battles of Cerro Gordo and Contreras in the summer of 1847. He also participated in the battles of Churubusco and Molino del Rey. He received a brevet promotion and was placed in command of a police company in Mexico City.