Ayer is a town in Middlesex County, Massachusetts, United States. Originally part of Groton, it was incorporated February 14, 1871 and became a major commercial railroad junction. The town was home to Camp Stevens, a training camp for Massachusetts volunteers during the American Civil War. Later, Fort Devens was established by the federal government to train New England soldiers for World War I. Fort Devens was a major influence in the area until its closure in 1994. The town’s population was 7,427 at the 2010 census. For geographic and demographic information on specific parts of the town of Ayer, please see the articles on Ayer (CDP) and Devens, Massachusetts.