The war of 1812 was a conflict fought between the United States and the United KIngdom, from June 1812 to February 1815. Historians in Britain often see it as a minor theater of the wars with Napoleon, while historians in the United States and Canada see it as a war in its own right.
From the outbreak of the Napoleonic War, Britain had enforced a naval blockade to choke off neutral trade to France which the United States contested as illegal under international law. Britain was pressing American sailors into the Royal Navy and sentiment grew increasingly hostile toward Britain. On June 18, 1812 President James Madison signed into law the American declaration of war. There had been heavy pressure from the War Hawks in Congress.
The US Navy, like most of the country was not prepared for the war. During the years following the American Revolution there was a general mistrust of standing military forces and the Navy had effectively ceased to exist with only 22 commissioned vessels.
In early fighting American warships were surprisingly successful in their early encounters with British warships. While the British blockade in the Atlantic was for the most part successful, the American efforts spurred the British to pour more ships and men in the the action. Despite superior numbers, the American Navy ships were successful because of their greater physical size and for the most part heavier cannons.
This war was the first testing of the new American Nation, and while it was never a clear victory on either side, the willingness of the American Navy to fight to the last man, where necessary, convinced an increasingly war weary Britain to sue for peace. The war became a millstone around the necks of British citizens, causing a slowdown of their economy and a huge expense to keep the blockade going. Finally on 24 December 1814, representatives met in Ghent, Belgium (then the United Kingdom of the Netherlands) and signed the Treaty of Ghent. The American Congress ratified it on 16 February, 1815. The willingness of both the US Army and the US Navy led to the willingness of the United Kingdom to settle for peace.
Want to know what the British were mainly worried about? Listen to this.