For geographic and demographic information on specific parts of the town of Ayer, please see the articles on Ayer (CDP) and Fort Devens.
According to the United States Census Bureau, the town has a total area of 24.8 km² (9.6 mi²). 23.4 km² (9.0 mi²) of it is land and 1.4 km² (0.6 mi²) of it is water. The total area is 5.75% water.
As of the census of 2000, there are 7,287 people, 2,982 households, and 1,774 families residing in the town. The population density is 311.9/km² (808.1/mi²). There are 3,154 housing units at an average density of 135.0 persons/km² (349.8 persons/mi²). The racial makeup of the town is 85.92% White, 5.70% African American, 0.26% Native American, 2.90% Asian, 0.14% Pacific Islander, 2.28% from other races, and 2.81% from two or more races. 4.69% of the population are Hispanic or Latino of any race.
There are 2,982 households out of which 29.4% have children under the age of 18 living with them, 42.9% are married couples living together, 12.2% have a woman whose husband does not live with her, and 40.5% are non-families. 32.8% of all households are made up of individuals and 8.9% have someone living alone who is 65 years of age or older. The average household size is 2.29 and the average family size is 2.94.
In the town the population is spread out with 24.0% under the age of 18, 8.9% from 18 to 24, 36.3% from 25 to 44, 18.9% from 45 to 64, and 12.0% who are 65 years of age or older. The median age is 35 years. For every 100 females there are 96.8 males. For every 100 females age 18 and over, there are 93.9 males.
The median income for a household in the town is $46,619, and the median income for a family is $61,968. Males have a median income of $44,092 versus $32,418 for females. The per capita income for the town is $26,400. 10.8% of the population and 6.1% of families are below the poverty line. Out of the total people living in poverty, 9.5% are under the age of 18 and 11.7% are 65 or older.