Ashby is a town in Middlesex County, Massachusetts, United States. The population was 3,074 at the 2010 census, which makes it the least populous municipality in Middlesex County.