Merrimac is a small town in Essex County, Massachusetts, United States, and on the southeastern border of New Hampshire, approximately 34 miles (55 km) northeast of Boston and 10 miles (16 km) west of the Atlantic Ocean. It was incorporated on April 11, 1876. It is situated along the north bank of the Merrimack River in the Merrimack Valley. The population was 6,338 at the 2010 census. Historically a manufacturing center, it has long since become a largely residential community. It is part of the Greater Boston metropolitan area.