From June 18, 1812 to February 16, 1815, the United States was at war with Britain. Canada was the battleground.
The War represents an extremely significant chapter in the history of Canada and the United States during which the Americans came very close to annexing Upper Canada (Ontario) and all territory west of it.
In 1793, Great Britain was forced into a war with revolutionary France that would last for the next two decades, with only one very brief respite of peace. The war became global in nature as Napoleon Bonaparte, Emperor of the French, sought to establish his dominance over Europe and threatened other parts of the World. By 1812, this global struggle was severely straining Britain’s resources.
After the Battle of Trafalgar in 1805, the British Royal Navy dominated the seas. The Royal Navy enforced a blockade of Europe, to prevent supplies of warlike materiel, food and other supplies from reaching their enemy. In pursuance of this blockade the navy forced the ships of neutral nations to enter British-controlled ports where contraband cargoes were seized. Neutral merchant ships were stopped on the high seas to be searched by British sailors....
...On June 18, 1812, the United States declared War on Great Britain. The primary American war objective was the conquest of British North America, primarily Upper Canada (Ontario) and Lower Canada (Quebec). This theatre of war would be the focus of American military action."
Source: The Government of Canada