During the early stages of the civil war, Mayer took sides with abolitionism, and wrote several articles in Harper's Magazine, stressing the role of African slaves' descendants in the South American Independence wars. He helped to establish a number of colored regiments. He joined the Union Army in July 1863 as a captain. Promoted to the rank of lieutenant colonel, he fought with distinction in Chattanooga, Olustee and the Siege of Petersburg, commanding the 45th U.S. Colored Infantry Regiment. At the time of Lincoln's assassination, Mayer and his men were at a party along with his friend Robert Lincoln. Mayer attended Abraham Lincoln's funeral, comforting his friend and family.