After college he moved to Illinois and then Iowa and taught in schools for African Americans. In 1856, Foster joined abolitionist John Brown in a series of attacks on proslavery settlements in Kansas known as Bleeding Kansas. He later moved to Nebraska and in 1862 enlisted in the 1st Regiment Nebraska Volunteer Infantry to fight in the American Civil War. After African American soldiers were authorized to join the Union Army in 1863, Foster volunteered to serve as an officer for a black regiment. He was commissioned a first lieutenant and joined the 1st Missouri Regiment of Colored Infantry. While an officer, Foster led in the education of the soldiers, many of whom were former slaves. The regiment was stationed in Louisiana and Texas and took part in the Battle of Palmetto Ranch. It also saw numerous casualties due to disease. Foster was mustered out in January 1866.
Lincoln Institute
After the war, Foster and other officers and soldiers of his regiment, together with the 2nd Missouri Regiment of Colored Infantry, organized and raised money to create a school for former slaves in Missouri. Foster advocated that the reopening of Central Methodist University include allowing black students to join, but he was rebuffed. He moved to Jefferson City, Missouri, and after some difficulty opened the Lincoln Institute with two students on September 17, 1866. The school struggled financially, and Foster employed Charles A. Beal, Henry Ward Beecher, and Frederick Douglass to serve as fundraisers with some success. Foster served as the school's president and sole teacher until 1868, when he hired W. H. Payne, an African American, to teach. Foster advocated that the school share in federal money set aside for higher education by the 1862 Morrill Land-Grant Acts establishing land-grant universities. This plan was rejected, but with the help of politicians James Milton Turner and Moses Dickson, it gained increased state funding, with the condition that Foster raise $15,000 first. With the help of the Western Sanitary Commission and the Freedmen's Bureau, Foster raised the money, and the school's finances were greatly improved. Under the Morrill Act of 1890, Missouri designated the school as a land-grant university, emphasizing agriculture, mechanics, and teaching. Foster left the position as principal of the school in 1870 and 1871 in favor of Payne, but returned to become principal for part of 1871.
In 1891, Foster was awarded an honorary doctor of divinity degree by Howard University. Foster married Jemine Ewing, daughter of John Logan Ewing and Elizabeth Cleland, on October 23, 1851, in Brooklyn, Illinois, with whom he had one son. Jemine died on October 3, 1853, in Jacksonville, Illinois. Foster remarried at Clay, Iowa on March 8, 1855, to Lucy Reed, daughter of Festus Reed and Sarah Ann Woodruff. With Lucy, Foster had eight sons and two daughters.