Image caption At the Battle of the Chateauguay near Montreal in 1813, an outnumbered Canadian, British and Mohawk force repelled the US troops

Canada today is seen as a harmonious nation of hockey, mounties and maple leaves, in peaceful contrast to its often fractious and noisy neighbour to the south. But Canadian-ness itself was born amid the blood, gunpowder and glory of the War of 1812, writes Grant Stoddard.

As a British-born newcomer to Canada, I've noticed Canadians see their Canadian-ness as the sum total of their shared values, interests and beliefs.

By contrast, in other places national identity is more typically linked to battles, popular uprisings and improbable triumphs in the face of adversity: the Boston Tea Party, the storming of the Bastille, the October Revolution.

This led me to assume that while Canada is a wonderful place to live, it lacked a rousing origin story.

Imagine my surprise when I discovered that the story of the birth of Canadian-ness - which began 200 years ago this week - is as rollicking, bloody, stirring and inspiring as they come.

Canadians famously cannot bring themselves to brag, so I am taking it upon myself to recount the series of events that paved the long road to Canadian nationhood. Hold on to your toque!

Challenges and disunity

Image caption De Salaberry led a combined forced of 1,350 that drove off 4,000 US troops.

In the years after the American Revolution, Britain set about creating a mirror-state to the north of the 13 rebellious former colonies.

Hoping in part to entice the US back into the empire, Britain aimed to demonstrate that life in North America could be happier and more stable under her administration.

There were challenges: the territory in what is now Canada was rugged, under-developed and thinly populated.

Furthermore, the main groups of people living there did not like each other very much.

First Nations tribes resented the unrelenting European expansion into the heart of the continent. Disaffected French Catholics had settled along the St Lawrence River in the early 1600s and remained after Britain finally wrested control of Canada from France in 1763. British inhabitants of Nova Scotia, known as the "14th Colony", had not joined their sister colonies in revolt.

Some Canadians were uninterested in receiving liberty and prosperity at the point of an American sword. So they took up arms Why the forgotten war still matters

And tens of thousands relocated north after the American War of Independence: refugee crown loyalists and former black slaves rewarded with their freedom for fighting alongside the British.

The new arrivals were so numerous that Britain carved a new colony - New Brunswick - out of Nova Scotia to accommodate them. Yet even after the influx, the US still had about 20 times the population of what was now called British North America.

The British government encouraged even more immigration from the US by offering free land and low taxes. These opportunist migrants, who had little loyalty to the British crown, were euphemistically called the Late Loyalists.

At the dawn of the 19th Century, what is now Canada was no melting pot or even patchwork quilt but rather a hodgepodge of disparate groups who held wildly varying opinions on British rule and American republicanism and a deep distrust of one another.

By 1812, with the British embroiled in war with France, US hawks moved to take advantage of their northern neighbour's disunity, finish the job of the revolution and kick the British off the North American continent once and for all.

Proponents of war were confident that the fractious Canadians would greet US forces as liberators, with former President Thomas Jefferson quipping that annexing the vast territory would be "a mere matter of marching" and could be completed within a few months.

Image caption Native leader Tecumseh was killed by a US soldier at the Battle of the Thames in Ontario, shown in a detail from an 1833 lithograph

One of the leaders of the invasion force was US General William Hull, a 58-year-old veteran of the revolution who had been reluctant to take part.

He promised the Canadians liberty and prosperity, while also threatening "instant destruction" and a "war of extermination" at the first whiff of collusion between the Canadians and the natives.

Though some Canadians took heed, others, regardless of their allegiances, were uninterested in receiving liberty and prosperity at the point of an American sword. So they took up arms.

Bravery and patriotism

In battles on both sides of the border, vastly outnumbered Canadian militiamen, British regular troops and First Nations warriors inspired by Shawnee warrior Tecumseh overcame the Americans.

Image caption Canada never rejected the British Crown as America did, and remains a loyal part of the Commonwealth

A force led by British Maj Gen Isaac Brock and Tecumseh captured Detroit from Gen Hull, taking almost 2,500 American regulars and militiamen captive with only 300 British regulars, 400 Canadian militiamen and 600 natives.

At the Battle of the Chateauguay near Montreal, French Canadians repelled a US attack. Under the leadership of Charles de Salaberry, 50 regulars, 400 volunteers, 900 militiamen and 180 Mohawks drove off 4,000-strong US force.

Despite their difficult history with British rule, Les Canadiens had proved their bravery and patriotism beyond a doubt.

Their victory inspired yet another improbable defence of Canada just over two weeks later at the Battle of Crysler's Farm, in which 900 British regulars and Canadian militiamen repulsed 8,000 US troops.

By the war's end, both York (now Toronto) and Washington DC had been put to the torch by invaders; the British bombardment of Ft McHenry in Baltimore had inspired a new national anthem; and Gen Andrew Jackson had routed the British Army at the Battle of New Orleans.

But the map of North America had hardly changed.

Image caption Canada's First Nations tribes' hopes for an independent state died after the War of 1812; above, three men who fought with the British, photographed in 1882

The US withdrew to well within the boundaries of the 13 colonies. Inexperienced British diplomats gave away her territorial gains at the negotiating table, while bullish and skilled US negotiators rejected the British-backed idea of an independent "buffer state" for the indigenous tribes between the US and British North America.

This betrayal of the natives hastened the demise of native autonomy in North America, as the US turned its attention from annexing lands in the north to pushing west toward the Pacific Ocean.

The War of 1812 was declared in Washington 200 years ago yesterday.

The British and Americans drew and the natives lost, leaving the fledgling Canadians with the best claim to victory.

In the spirited defence of their way of life, they surprised both the invaders and one another with their resourcefulness, co-operation and tenacity in the face of an invasion force with an overwhelming numerical advantage.

In that sense, their struggle was not unlike the American Revolution a generation earlier.

What Canadian-ness actually means continues to evolve and remains a perennial topic of discussion both domestically and internationally.

Nevertheless, its beginnings can be traced back to 18 June 1812, when her fractious inhabitants stood together against subjugation by a foreign power.

The 33.5 million people living in Canada today - fully one-fifth of whom are foreign-born - have this patchwork vanguard to thank for their country's steady path to progressive prosperity.