Thomas Jefferson served his second term as US President from 1804 to 1808. During his term, in 1805, the world balance of power shook as Admiral Nelson's ships beat Napoleon's navy at the Battle of Trafalgar, and as Napoleon bested the allied Russo- Austrian forces at Austerlitz that same year. France now had unquestionable control of the European continent, and Britain, held unquestionable mastery of the seas. For the next decade, neither power would seek to challenge the other in their element. The two European powers took to fighting each other indirectly, through economic warfare. Napoleon, hoping to strangle Britain's economy by preventing British goods from being exported to Europe, closed off all European ports in his Continental System.
As a countermeasure, in 1806 Britain passed the Orders in Council. According to these regulations, US ships could not land at a European port without first stopping at a British port. Napoleon retaliated with a harsh measure, demanding the seizure of any ship that landed in Europe after stopping in Britain. The warring French and English economic measures wreaked havoc with the American economy.
Also upsetting to Americans was the British practice of impressment. Always in need of men, British ships would stop American ships, capture sailors (sometimes violently), and force them to serve in the British navy. The crews of British ships staffed in such a way were often called "press-gangs". In 1807, off the Virginia coast, the US Naval Vessel Chesapeake was approached by a British vessel, who demanded to board so that it could reclaim "deserters" who were with the United States. The Americans refused. The British ship opened fire on the Chesapeake, killing and wounding several. In the end, the outgunned Chesapeake had to surrender four sailors to the British.
Americans were outraged by the Chesapeake incident, and a war might have broke out right then if not for Jefferson's restraint. The majority of Americans pushed for war, but Jefferson opted for an embargo against the British. Congress passed the Embargo Act toward the end of 1807, which altogether stopped exports out of US ports.
The embargo backfired, shutting down New England's trade and leaving the South and West with piles of unsold goods. By 1808, illegal trade across the US-Canada border was rampant. Americans started calling the embargo the "dambargo". Still convinced in his policies, Jefferson passed harsh laws to enforce the embargo. When secession talk started brewing in New England, the home of the anti-Jeffersonian Federalists, Jefferson realized that enough was enough. On March 1, 1809, the Embargo Act was repealed, to be replaced with the Non-Intercourse Act. This act allowed trade with everyone except Britain and France. Cleaning up the embargo mess was left to James Madison, Jefferson's successor as president.
The War of 1812, and the events leading up to it, all occurred under the shadow of the Napoleonic Wars. The Napoleonic conflict, which embroiled Europe in fighting from the 1790s to 1815, can in many ways be thought of as a "world war", in the sense that it really did have impacts throughout the globe. The War of 1812 began largely because the US got caught up in economic warfare between France and Britain. Furthermore, Britain was never able to fully commit to the war against the US because it had such pressing concerns in Europe, where the British isles themselves seemed to be facing the threat of French invasion if Napoleon could not be defeated. In all, Britain felt that maintaining good relations with the US was less important than hurting Napoleon economically, so that fewer British soldiers would die fighting against his European empire. The British and the Napoleonic measures, aimed at hurting each other, ended up greatly hurting US trade, when US merchants only wanted to be neutral traders.