Ayer is a census-designated place (CDP) in the town of Ayer in Middlesex County, Massachusetts, United States. The population was 2,868 at the 2010 census.