During the battle of Williamsburg men of his section were swept back by a rush of Confederate Cavalry. Lieutenant Barlow, with a single soldier to help him, threw one of the guns into the battery, loaded and fired it in face of enemy, and fought them off. At Hanover Court House he took one gun to the picket line, and with it repelled a Confederate regiment with canister shot. He was commended by General George McClellan for this action and was brevetted Captain. At the end of July 1862, he was transferred to the Topographical Engineers, and in March 1863 to the Corps of Engineers.
He served as Assistant Professor of mathematics at West Point for 6 months, also teaching geography, history and ethics (they were short-handed at USMA in those days).
In June 1863, he returned to Army of the Potomac and fought through Gettysburg. From that point on he built a number of bridges, including one over the Rappahannock at Kelly's Ford, November 1863. In February 1864 he returned to the mathematics dept. In June he went to Georgia and served as chief engineer of Sherman's XVII Army Corps. On sick leave from August to November and then back in charge of the defenses of Nashville. He was still in the West when the war ended.
He stayed in the engineers and supervised construction of forts in Florida, New York and Connecticut. He worked on harbors on the Great Lakes and along the Hudson River. He was involved in opening a canal at Mussell Shoals. In the 1870's he conducted a geological study, under Dr. F. V. Hayden, which became the first government exploration of the Yellowstone Region. His work resulted in the formation of Yellowstone National Park, and its publication gave him a lasting place in the country's history. A great part of his valuable collection of data and photographs was destroyed in the Chicago fire, as was his first copy of Cullum's Register. He promptly ordered three copies of the register and completed his admirable report on the exploration from memory. In 1872 he accompanied a surveying expedition for the Northern Pacific Railroad. The party was attacked by 1,000 Indians under Sitting Bull. The attack repulsed by an escort of 400 men. His report of the expedition was highly praised by General William T. Sherman.
In the 1890's, he commanded a joint commission of engineers from both countries who worked together surveying and placing permanent markers between the US and the Mexican Republic from El Paso to the Pacific Ocean. On May 2, 1901, he became Brigadier General and Chief of the Corps of Engineers, retiring from active duty the next day.
He was one of the classmates that Ames had described as being "seized by a perfect mania for getting married." He married Hessie McNaughton Birnie in the Church of Epiphany, Washington, DC, on the day after Christmas, 1861. They moved to a honeymoon home at 55 Pennsylvania Avenue. Mrs. Barlow died many years later, and the widower married Alice Stanton Turner on September 17, 1902. After he retired, they made their home in New London, Connecticut.
In 1912-1913, he was President of the Association of West Point Graduates. In the winter of 1913-14, the couple took a trip to the Holy Land. There taken ill. Died in Jerusalem, February 27, 1914, at the age of 76. His funeral was held 2 months later at Fort Myer, Virginia, with his burial in Arlington National Cemetery.