New Hampshire and Maine were founded in the 1620s as proprietary colonies belonging to Captain John Mason and Sir Ferdinando Gorges.
During the English Civil War (1642-49), the Gorges family - who were royalists - had difficulty managing their colony in Maine, and had essentially left it to its own devices, while at the same time the Massachusetts Bay colony was growing in both population and economic ambitions.
Seeing an opportunity to expand its boundaries, the government of Massachusetts send emissaries to the towns of Maine asking if they were interested in being annexed to the southern colony. Unhappy with the political instability of the colony - especially Gorges' inability to protect their land rights, many inhabitants agreed.
Thus in 1652, Maine was formally annexed to Massachusetts Bay, and became known as York County.
Massachusetts Bay justified the annexation on the basis of their colonial charter, which fixed their boundary three miles north of the Merrimack River. However, people did not know at the time the charter was issued that the Merrimack wends northward from the coast and can be traced far into the interior.
On the other hand, New Hampshire remained a proprietary colony and thus escaped the grasp of an expanding Massachusetts.