Edward Richard Sprigg Canby began his military career after graduating from the United States Military Academy second to last in 1839. Following graduation Canby served in the Seminole War as well as in campaigns against Native Americans in Arkansas. During the Mexican-American War, he served as a chief of staff of a brigade, and received brevet promotions of major and lieutenant colonel for his actions during the battles of Contreras, Churubusco, and Belén Gates. Following the conflict, Canby served in numerous posts throughout the west, and was in command of Fort Defiance in the New Mexico territory when the Civil War broke out.
He was appointed to colonel of the 19th Infantry on May 14, 1861 and was made commander of the Department of New Mexico. He first commanded in combat during the Battle of Valverde, where he was defeated, though his troops eventually forced the Confederates to retreat after the battle of Glorieta Pass. On May 31, 1862 Canby was promoted to brigadier general, and was ordered to the East where he served in mostly staff duties as well as in New York City after the New York draft riots. On May 7, 1864 he was promoted to major general and was placed in command of the Military Division of West Mississippi. He set out to capture Mobile, Alabama, and commanded his men during the campaign. Canby planned the expedition which eventually led to the fall of Mobile on April 12, 1865. At the end of the war, Canby accepted the surrender of Confederate armies under General Richard Taylor and General Edmund Kirby Smith.