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 is a major influence on the area, although it is considerably smaller than when it was first closed in the mid-1990s. 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 and Devens, Massachusetts.