The War of 1812, in which the United States invaded Canada, may be the most crucial and most bungled, the least understood and least remembered war the young nation ever fought.

It was the first time that America invaded another nation, with near-disastrous results. It was just 22 years after the ratification of the Constitution that created the United States we know. It was the first critical test of democratic leadership on an international scale that would decide whether the grand experiment of self-government would survive or collapse.

The latter was a distinct possibility. Never in the history of American warfare has this nation witnessed such an exhibition of cowardice, indecisiveness, incompetence and laziness in the Army’s senior officer ranks. Battle after battle was lost, untrained troops were sacrificed in fights they could never win, territories won were quickly squandered and the chain of command was ignored to near-treasonous levels.

More important, an American defeat likely would have resulted in Canada’s annexation of New England or in the return of those former colonies to the British crown. The Southern and Middle Atlantic states might have gone their separate ways. New wars could have broken out on the North American continent, involving Britain, France, Spain or Mexico, over control of the newly purchased Louisiana Territory. Five New England states met in secret convention to debate secession from the Union.

Considering the critical role that the United States has played in global affairs in the nineteenth, twentieth and twenty-first centuries, a defeat could have changed the face of today’s world.

The idea of separate states united under a central government was fragile and untested. The Civil War lay some 50 years ahead, but the economic, political and social fissures that caused it had already appeared. Former Vice President Aaron Burr had conspired with Army officers and planters to slice off southern and western lands to forge a new nation. From every corner, America was challenged: by Barbary pirates looting America’s shipping; by battling European nations, intolerant of America’s neutrality, who wanted to draw the young country into the Napoleonic wars, and by Native Americans armed by the British to stymie westward expansion.

The young country was provoked, even bullied, into the War of 1812. Great Britain routinely violated maritime law and interfered with American shipping. American sailors suspected—often for the flimsiest of reasons—of being British deserters or even British-born were forced to serve on British warships. Garrisons like Fort Mackinac in upper Lake Huron, ceded to the United States by treaty after the War of Independence, were slowly and grudgingly surrendered.

So the United States had ample reason to take up arms, but it harbored intentions beyond simple self-defense: to extend America’s hegemony beyond its borders into British Canada and Spanish Florida. Such nationalist stirrings eventually would become embodied in the idea of a Manifest Destiny—an America that was fated to extend from ocean to ocean.

Whatever America’s motives, the men who took on the army and navy of Great Britain were woefully unprepared for the task. It was a comedy of errors from the outset. Communication was badly mishandled or utterly ignored. Never before or since was a field general court-martialed for incompetence and sentenced to be shot. Soldiers, often ill trained and poorly supplied, lurched from defeat to defeat at the hands of the British, the Canadian militia and their Indian allies. One miscalculation triggered another and another. Public enthusiasm for the war cooled, criticism was first whispered and eventually led to outright condemnations and recriminations. Funding for the war dried up. Commerce and trade ground almost to a halt. Political crises dogged President James Madison. Troops that hadn’t deserted were starving, freezing or dying in bogs and swamps.

The war’s promoters never imagined that it would be fought on American soil, but the abortive invasion of Canada brought the fighting home. On Chesapeake Bay, British ships attacked Maryland and Virginia settlements, encouraged slave uprisings and laid siege to Washington, D.C. British warships blockaded ports and strangled commerce. The economy turned sour, and the federal government scrounged for loans.

America had virtually no Navy—its warships numbered in the single digits—while Great Britain had 900. The oceans of the world were virtually a British lake. America’s regular army comprised about 5,000 officers and men; Britain’s numbered in the hundreds of thousands. America thought it could rely on its the motley militias of the separate states, some of which refused to fight outside their states and all of which were comprised of undisciplined, inexperienced citizen soldiers who often had to supply their own arms and provisions.

In the face of such odds, America—astonishingly—declared war on Great Britain.

The War of 1812 was, in a word, madness.