In June he returned to Boston and enrolled in Harvard Law School, but by September 1862 became a first lieutenant in the 44th Massachusetts regiment. When the United States Colored Troops (USCT) were formed for African-American recruits, he was promoted to captain on March 31, 1863, of the 54th Massachusetts. However, the number of volunteers was higher than expected, so he was promoted to lieutenant colonel, and helped organize the 55th Regiment Massachusetts Volunteer Infantry under command of Norwood Penrose Hallowell. The 54th's role in the Second Battle of Fort Wagner was depicted in the film "Glory". The 55th moved into their former barracks, and was ordered to embark in July 1863. They served building trenches on Folly Island supporting the siege of Charleston, South Carolina. When Hallowell had to resign for treatment of an old wound, Hartwell was promoted to command the regiment on November 3, 1863.