EASTPORT — In the late afternoon of July 18, 1814, the soldiers manning Fort Sullivan were greeted with an awesome and frightening sight.

The fort, perched on a promontory behind what is now Shead High School, had sweeping views of the passages and islands of Passamaquoddy Bay, which for two years had been the quiet front line between two warring powers: British North America and the young United States. Fifty soldiers had whiled away the days, watching small boats shuffle to and fro across the bay, many of them chock-full of contraband but representing no military threat to American control of Eastport.

Now a 74-gun British ship of the line was barreling through Head Harbor Passage bound straight for town, accompanied by three armed auxiliaries, an assault ship, and troop transports carrying nearly 1,000 soldiers. As the tiny American garrison readied its six cannons, the invasion fleet anchored beneath the fort, guns and mortars trained above.

Resistance was futile. Maj. Perley Putnam surrendered his garrison. British troops swarmed the town, taking the troops into custody, seizing the customs house, and raising the Union Jack over Fort Sullivan. Within a few weeks, all of eastern Maine was under foreign occupation, and communities from Camden to York braced for the expected attack.

The War of 1812, which broke out two centuries ago this month, was a watershed moment in Maine’s history. The British occupation and Boston’s lackluster response to it prompted Mainers to reclaim their independence from Massachusetts, from which it had been ruled as an internal colony since the 1650s.

“Maine’s very negative experience with the War of 1812 accelerated the political process that would lead to Maine becoming a separate state in the Union,” says Pulitzer Prize-winning historian (and Portland native) Alan Taylor of the University of California–Davis, author of “The Civil War of 1812.” “There was a feeling that the Massachusetts government didn’t have the best interests of Maine at heart.”

The war is poorly understood and largely forgotten — a peculiar and humiliating conflict that exposed the weakness of the young United States’ central government and profound differences between its regions. In a war that saw Washington plundered and New Orleans placed under siege, the District of Maine was perhaps the most profoundly affected region of all, with much of its territory under foreign control and many of its people deeply disillusioned with their colonial overlords in Boston.

Prior to the invasion, Mainers had been divided on whether to pursue independence from Massachusetts, which had annexed Maine in the mid-17th century in the aftermath of the English Civil War. (Maine’s leaders had backed the king, while Massachusetts backed the victorious forces of Parliament, which gave them free reign to absorb what Bostonians came to refer to as “the Eastern territories.”

For the better part of a century, settlers in what were then backcountry towns — Whitefield, Jefferson, Liberty and many others — had been engaged in an armed insurrection against Bay State land barons like Samuel Waldo, James Bowdoin and Henry Knox. People in the wealthier port towns like Portland, Wiscasset and Castine were opposed to independence, which for various technical reasons would have disrupted coastal trade.

When President James Madison declared war on Britain in 1812, New Englanders from Greenwich, Conn., to Eastport were appalled. The conflict disrupted the region’s trade with London and the British Caribbean, and many Yankees felt the U.S. should be fighting Napoleon Bonaparte, not harassing his opponent.

Regional solidarity collapsed in the summer and fall of 1814, as British forces surged down the coast, occupying Machias, Blue Hill, Castine and Belfast, looting Hampden and Bangor, and setting fire to a Biddeford shipyard. Residents of Wiscasset expected the village “would be laid in ashes” at any moment, while thousands of militiamen rallied to defend Portland from the expected assault.

“The whole District of Maine is threatened by a raving foe,” Washington, D.C.’s leading newspaper lamented in October, “and scarcely a soldier of the U.S. troops is there to assist in repelling invasion, although thousands have been enlisted in that part of the country.”

With the federal government already bankrupted by the long war, Mainers and the White House alike looked to Massachusetts to take action to defend southern Maine and liberate the occupied zone. Instead, legislators in Boston chose to do nothing, while Gov. Caleb Strong carried on secret diplomacy with his British counterpart in Nova Scotia, hoping to secure assistance in the event the Bay State made good on threats to secede from the United States. When Maine’s William King met with Strong to discuss an expedition to push the British out of Maine, the plan was promptly leaked to Boston newspapers and thus to the British.

Fortunately, the British never moved on southern Maine, in part because they had overestimated the strength of its defenses and partly because they thought they could still win over southern New England. “If you’re in Boston, you might say, OK, take Castine and Eastport, what do we care? But take Portland — that might be a problem,” says Joshua M. Smith, associate professor of humanities at the U.S. Merchant Marine Academy in King’s Point, N.Y., who has written widely on the conflict. “The British didn’t want to antagonize Boston. Throughout the war they were pretty clever at playing Americans off each other.”

Meanwhile, Mainers reacted in a variety of ways to the occupation. “Some people were shocked and numbed by it and became obsessed with survival, others became rebellious, viewing the invasion as a sort of punishment by God for being wicked,” Smith says. “Others see it as an opportunity to make money.”

Smuggling was rampant, with Eastern Maine serving as the transshipment hub for a massive black market trade between Halifax and Boston. “Then as now, Americans didn’t want to do without their consumer goods, and the source wasn’t China, it was the factories of England and Scotland,” says Taylor. “This created an enormous opportunity for smugglers, and the best place to do it was from Maine to New Brunswick and Nova Scotia.”

Risk was low because the British encouraged the trade, collecting customs fees at Castine. Huge fortunes were made, and so much money was collected at Castine, it was used to endow a new college in Halifax, now Dalhousie University, the most prestigious in Atlantic Canada.

Even the most famous incident in Maine during the war — the clash of the USS Enterprise and HMS Boxer — was the result of smuggling. “A group of New England merchants had sent a representative to New Brunswick to meet the captain of the Boxer and essentially hired him to escort one of their merchant ships down to Maine,” protecting it from privateers and other British warships, says James Nelson, the Harpswell-based author and maritime historian.

The complex plan included a mock battle off Popham Beach between the Boxer and one of the merchants’ vessels, which went off without a hitch. “Unfortunately, the gunfire of the fake battle drew the attention of the Enterprise, which was in Portland at the time and engaged the Boxer in battle two days later,” says Nelson.

Ultimately, the Enterprise — a 16-gun brig, not the famous “Old Ironsides” — defeated the British warship in a battle that took the lives of both ships’ commanding officers. (They are buried side by side in Portland’s Eastern Cemetery.) An incriminating note was found in Boxer Capt. Samuel Blyth’s pocket, Nelson says, revealing the plot.

Along the border itself, few were interested in fighting, either before the invasion or after. When the town fathers of Calais announced they would have to cancel the 1812 July 4th fireworks display to comply with orders to conserve gunpowder, local lore goes, the people of neighboring St. Stephen, New Brunswick, loaned them the powder to allow the show to go on. After the invasion, resistance was slim to none.

“People in easternmost Maine socialized with people from St. Andrews, New Brunswick, and nobody on either side of that border had a burning desire to kill each other,” Taylor says. “They had a burning desire to keep socializing and trading and marrying each other.”

While the war failed to drive a wedge between eastern Maine and New Brunswick, it proved devastating for relations with the Bay State. When the war ended in February 1815, Gov. Strong became the focus of hatred for his failure to defend Maine. Mainers ridiculed him as the “Hero of Castine” and some proposed giving him a sword made of soft white pine to symbolize “our estimation of the prompt and efficient protection he afforded the District when invaded by the enemy.”

Worsening matters, in the aftermath of the war, Boston made little effort to re-establish jurisdiction over Eastport, which the British insisted was really part of New Brunswick. (The town, one British official insisted, was as British “as Northamptonshire.”) For years, residents had to travel 15 miles to Dennysville to access a U.S. post office, while town merchants were forced to operate out of Lubec, just across the harbor. The British didn’t finally withdraw until June 1818.

By then, it was too late to undo the damage. Massachusetts’ ruling party, the Federalists, were routed in Maine, raising the possibility that they might lose power. “They became anxious to get rid of Maine after the war because its population was growing and much of its population voted for the (rival) Jeffersonian party,” says Smith. “The Maine tail was starting to wag the dog.”

With divorce supported by both parties, Mainers would go ahead with a referendum on statehood. Although the issue became entangled in the rivalry between slave and free states — ultimately resolved by the 1820 Missouri-Maine Compromise — the great impetus for it came from the division between two parts of New England and the trials of an ill-remembered war.

Colin Woodard is state and national affairs writer at The Portland Press Herald/Maine Sunday Telegram. He is the author of four books, including “The Lobster Coast,” a cultural history of coastal Maine. Woodard can be contacted at 791-6317 or at: cwoodard@mainetoday.com