Allan was born on November 12, 1837, at Winchester Gardens, near Winchester, one of two children, both sons, of Thomas Allan and Jane Dowdell George Allan. After being educated in a local private school, he taught in Jefferson County and in Winchester to earn enough money to enroll in the University of Virginia in 1857. Allan excelled at debate and graduated with honors in 1860 with an MA in applied arithmetic. He moved to Loudoun County where he was assistant to the principal of Bloomfield Academy when the Civil War began. Allan enlisted in the Confederate army and served as a clerk in the quartermaster department under Stonewall Jackson. In 1862, sponsored by University of Virginia classmate Alexander “Sandie” Pendleton, Allan took the ordnance officer examination. He passed with the highest score and on December 27, 1862, became a captain of artillery. On January 19, 1863, he was appointed to Jackson’s staff as chief of ordnance of the Second Corps, Army of Northern Virginia. He served throughout the war, advancing to the rank of major on April 25, 1863, and lieutenant colonel on March 28, 1864. He was assigned to Jubal Early’s Shenandoah Valley command on March 1, 1865.