Originally part of Kittery, the area later comprised by Berwick was settled about 1631 and called Kittery Commons or Kittery North Parish. It was later called Unity after the ship that transported Scots prisoners of war from the Battle of Dunbar in 1650 to the colonies. (These Scots had been force-marched to Durham Cathedral in Durham, England, then tried for treason for supporting Charles II rather than Oliver Cromwell, Lord Protector.)
Landing in Massachusetts, the royalist soldiers were sold as indentured servants, many of whom went to work at the Great Works sawmill, located on the Great Works River, until they were able to pay for their own freedom. (George Gray, formerly of Lanark, Scotland, was an example of the 150 prisoners who endured this ordeal. In 1675, he defended his family and lands when the community was attacked during King Philip's War, and died in Unity in 1693. His descendants would populate other areas of Maine, notably Deer Isle and Stonington, Maine ).
The raid by Indians in 1675 was the first of several during what was known as King Philip's War. In 1690–1691 during King William's War, the village was burned and abandoned in the Raid on Salmon Falls. It was resettled in 1703 and called Newichawannock, its old Abenaki name. In 1713, it was incorporated by the Massachusetts General Court as Berwick, after Berwick-upon-Tweed, England. The first schoolhouse in the state was built here in 1719. The town was raided numerous times during Father Rale's War. Berwick was once considerably larger in size, but South Berwick was set off in 1814, followed by North Berwick in 1831. Lumbering was a principal early industry. The first lumber exported from the American colonies was clapbords and barrel staves loaded aboard Pied Cowe at South Berwick in 1634. Beginning in the 19th century, Berwick had a symbiotic economic relationship with Somersworth, New Hampshire, the mill town to which it is connected by bridge.