Allan was born in Birmingham, England, on February 26, 1842, the son of John Allan and Ann Allan. He attended parochial schools and received training as a typesetter in Birmingham. In 1863 he immigrated to the United States, and on June 17, just six weeks after his arrival, enlisted as a private in George Armstrong Custer’s 7th Michigan Cavalry. He was wounded at Shepherdstown on August 24, 1864, and discharged from the army in Washington, D.C., in the summer of 1865.
Allan bought a small farm in Prince Edward County, where he studied law by himself. In December 1867 he was admitted to the bar and afterward moved to Farmville. He unsuccessfully applied for a position with the Bureau of Refugees, Freedmen, and Abandoned Lands and soon became active in the local Republican Party and as a statewide leader of the Union League of Virginia. On October 22, 1867, Allan and James W. D. Bland were elected to represent Appomattox and Prince Edward counties in the constitutional convention that met in Richmond from December 3, 1867, to April 17, 1868. Of the 2,306 votes Allan received, only one was cast by a white man, the rest by African Americans, many of whom had recently been slaves. Allan served on the Committee on County and Corporation Courts and County Organizations and chaired the Committee on Printing and was prominent at the convention despite his youth, the brevity of his residence in Virginia, and his inexperience in politics. He criticized the constitution that the convention produced because he feared that it would not sufficiently protect the rights of the former slaves and would prolong hard feelings by virtue of its clauses imposing political restrictions on former Confederates. Out of party loyalty, he nevertheless supported the constitution at the referendum that ratified it in 1869.