Beginning in 1860, Hamlin was a member of Company A of the Maine State Guard, a militia unit. When the company was called up in the summer of 1864, Hamlin was told that because of his position as Vice President, he did not have to take part in the muster. He opted to serve, arguing that he could set an example by doing the duty expected of any citizen, and the only concession made because of his office was that he was quartered with the officers. He reported to Fort McClary in July, initially taking part in routine assignments including guard duty, and later taking over as the company cook. He was promoted to corporal during his service, and mustered out with the rest of his unit in mid-September.