Fortifications at this site have protected Portsmouth Harbor since 1689, when earthworks and a small blockhouse were built at what was then called Pepperrell's Garrison after settler William Pepperrell. In 1715, the Massachusetts Bay Colony decided to build a permanent fort to protect the river and harbor, and in 1720 a blockhouse named Fort William was built there, where a Naval Officer collected duties from ships entering the harbor. Because the Pepperrell family were loyalists to the Crown, local rebels took over their property during the Revolution, including the fort, which the New Hampshire Militia occupied until 1779. In 1808, Massachusetts gave land to the federal government for a new fort named Fort McClary in honor of Major Andrew McClary, a New Hampshire native who served at the Battle of Bunker Hill in 1775. That fort had two cannon batteries: a semicircular wall protected a Lower Battery below the present blockhouse site, while an Upper Battery with barracks, quarters, a cookhouse, and a powder magazine of brick stood where the blockhouse now stands. In 1844, a hexagonal blockhouse replaced the Upper Battery, with upper floors used as officers' quarters and two brick riflemen's houses built on either side. The federal government deactivated the fort in 1846, but during the Civil War, after Confederate raiders captured and destroyed a ship in Portland Harbor and fears rose of attacks on the Maine coast, a granite bastion and powder magazine and a guardhouse and hospital were added. Work was suspended five years after the Civil War ended, leaving the outer wall incomplete, and soon this style of fort was considered obsolete, so Fort McClary remained unfinished. The buildings there today reflect several periods of construction as the fort was upgraded and modified to meet local defensive needs. The site was manned during five wars: the Revolutionary War, War of 1812, Civil War, Spanish-American War, and World War I, though like most Maine forts it saw little conflict. Shortly before the 1864 election, Maine's Hannibal Hamlin reported for active duty at Fort McClary with his Coast Guard unit even though he was then Vice President of the United States.