Dunstable was named after its sister town Dunstable, England. There are several theories concerning its modern name. In one version, legend tells that the lawlessness of the time was personified in a thief called Dun. Wishing to capture Dun, the King stapled his ring to a post daring the robber to steal it. It was, and was subsequently traced to the house of the widow Dun. Her son, the robber, was taken and hanged to the final satisfaction that the new community bore his name. Another theory is that it comes from the Anglo-Saxon for "the boundary post of Duna". A third version is that the name is derived from Dunum, or Dun, a hill, and Staple, a marketplace.
Dunstable was first settled by Europeans in 1656 and was officially incorporated in 1673. It is likely named after the town of Dunstable in Bedfordshire, England, home of Edward Tyng, the town's first settler. The original township of Dunstable, granted in 1661, consisted of two hundred square miles, including the Massachusetts towns of Dunstable, Pepperell, Townsend and Tyngsborough, the New Hampshire towns of Hudson, Nashua and Hollis, and parts of other towns as well. Increases in population leading to subsections becoming independent towns and the delineation of the northern boundary of Massachusetts in 1740 placed the northern part of Dunstable (present day Nashua) in New Hampshire, so the southern part remains the Dunstable of today.
Today, Dunstable, in the face of urban sprawl, has held onto a largely rural character.
According to the United States Census Bureau, the town has a total area of 16.7 square miles (43 km2), of which 16.5 square miles (43 km2) is land and 0.2 square miles (0.52 km2) (1.13%) is water. Dunstable is bordered by Pepperell to the west, Groton to the south, Tyngsborough to the east, and Nashua and Hollis, New Hampshire, to the north.
The main road and only numbered route through Dunstable is Route 113; the nearest limited-access highway is US 3, two miles to the east. Dunstable does not have any public transportation in the form of trains or buses.
As of the census of 2000, there were 2,826 people, 923 households, and 798 families residing in the town. The population density was 171.0 people per square mile (66.0/km2). There were 944 housing units at an average density of 57.0 per square mile (22.0/km2). The racial makeup of the town was 97.49% White, 0.11% African American, 0.04% Native American, 1.52% Asian, 0.07% from other races, and 0.78% from two or more races. Hispanic or Latino of any race were 0.53% of the population.
There were 923 households, out of which 47.5% had children under the age of 18 living with them, 76.7% were married couples living together, 7.2% had a female householder with no husband present, and 13.5% were non-families. 10.3% of all households were made up of individuals, and 3.7% had someone living alone who was 65 years of age or older. The average household size was 3.07 and the average family size was 3.31.
In the town, the population was spread out, with 31.1% under the age of 18, 4.4% from 18 to 24, 31.4% from 25 to 44, 26.2% from 45 to 64, and 6.8% who were 65 years of age or older. The median age was 37 years. For every 100 females, there were 97.7 males. For every 100 females age 18 and over, there were 93.3 males.
The median income for a household in the town was $86,633, and the median income for a family was $92,270. Males had a median income of $61,425 versus $39,946 for females. The per capita income for the town was $30,608. About 2.1% of families and 1.9% of the population were below the poverty line, including 2.4% of those under age 18 and 2.1% of those age 65 or over.