Ayer is a town located in Middlesex County, Massachusetts.
The town's history dates back to 1667 when the first mill, used to grind corn in the agricultural community, was built. The Town was incorporated in 1871 and was named in honor of Dr. James Cook Ayer, a prominent resident of Lowell who provided the funding for the recently restored Ayer Town Hall.
During the Civil War an army camp, Camp Stevens, was established here; that camp later became known as Camp Devens, and eventually as Fort Devens. The presence of thousands of military and civilian personnel on the base shifted Ayer's commercial development towards meeting their needs until Fort Devens was closed in 1994.