This week 200 years ago, Congress passed and President James Madison signed a declaration of war against Great Britain, then the world’s most powerful nation. Our young country had already fought three wars since adopting the Constitution in 1788, yet this marked Congress’s first such declaration, and the highly controversial act passed without a single vote from a member of the Federalist party. The War of 1812—mostly forgotten today—helped shape the national character and greatly refined Americans’ understanding of the common defense.

For years, lawmakers had been scrimping on defense spending, saving money in the short term while weakening the country’s long-term defenses. These lawmakers, and all Americans, would soon learn an expensive lesson.

The reasons for war given by Congress included attacks on U.S. shipping and the British practice of impressement—taking sailors off American vessels and forcing them into service with the British navy. In previous years, the British navy had detained dozens of U.S. ships and seized thousands of dollars’ worth of American goods. The U.S. viewed Britain’s continued policy of impressement as a violation of the rights of its citizens and a threat to U.S. sovereignty. “Our power upon the waves enables us to dictate the terms,” wrote one British journalist aptly characterizing the British position of coercive dominance. “Not a sail should be hoisted…without paying a tribute.” Tribute was synonymous with submission and so threatened America’s sovereign independence.

Earlier attempts to peacefully persuade Britain to respect U.S. sovereignty were unsuccessful. President Thomas Jefferson’s failed 1807 embargo forestalled open conflict while doing great harm to the American economy. Madison’s Secretary of State, James Monroe, summed up the situation: “the British government has not believed us. We must actually get to war before the intention to make [war] will be credited either here or abroad.”

Despite a bold declaration, however, years of inadequate defense spending due to congressional neglect had left the United States woefully unprepared to fight a full-fledged war. America’s navy consisted of 16 vessels, while Britain ruled the waves with some 600 warships. The connection between congressional defense spending and the nation’s material security was about to be exposed.

For two years, Americans fought Britain to a stalemate, but when U.S. land forces invaded Canada, they were quickly repulsed, revealing that the militia-dependent U.S. army was insufficient. As Britain began to win the contest against Napoleon in Europe, Britain shifted its forces to North America. In August 1814, a British army landed on the shores of Maryland eager to conquer the U.S. capital. The purely defensive American gunboats provided by Congress under Jefferson’s Administration provided no defense at all and, within 11 days, the British had captured Washington and razed its public buildings. Peace through means other than strength was proving to be very expensive.

After burning the Houses of Congress, the White House, and the Library of Congress, the British withdrew to their ships and attempted to capture strategically important Baltimore. Blocking the British navy’s path into Baltimore harbor was Fort McHenry—one of the peacetime defensive coastal fortifications authorized by Congress under George Washington’s Administration in 1794. The British navy attacked on September 13, but the defenders of Fort McHenry stood firm for more than 24 hours, withstanding 2,000 artillery shells. As the Americans held hour after hour, Francis Scott Key, who was being temporarily held against his will aboard a British ship within view, penned the words that would be sung by every American: the “Star Spangled Banner.” This victory and several key American naval victories against the British were directly attributable to earlier congressional appropriations for forts, frigates, and officer training.

On the high seas, earlier investments in the navy also paid off. The few frigates that existed were able to carry the war to the enemy. U.S. ships had defeated several British ships in sea combat. During the war, American ships had sailed the waters of the Americas, the Caribbean, the Atlantic sea lanes, and even Ireland to impede British trade. These naval actions were the most effective defense America possessed during the war. The British Naval Chronicle acknowledged the situation: “It must be allowed the Americans have fought us bravely at sea, they have almost in every instance been successful; and there cannot be a doubt they will speedily become a respectable, and ere long, truly formidable naval power.” These U.S. ships had been authorized and built decades earlier at the requests of Presidents George Washington and John Adams, and they were the fruits of the largest federal programs to that time.

It is often said today—and it was true in the 18th and 19th centuries as well—that nations go to war with the army they have. Presidents then, as now, depended largely on the military built up by their predecessors to defend the country. Instructively, the War of 1812 highlights the wisdom of Washington’s and Adams’ military procurements, but also reveals the insufficient spending of Congress in Jefferson’s first Administration and an imprudent reliance on purely defensive gunboats and militia prior to 1812.

Though Great Britain and America soon negotiated a peace (the Treaty of Ghent was signed on Christmas Eve 1814), the ultimate cost of the war was much more expensive than increased military preparations would have been. In an attempt to prevent Congress from dismantling the military and navy as it had done following past wars, President Madison highlighted “important considerations which forbid a sudden and general revocation of the measures that have been produced by the war.” Instead, Madison requested that Congress authorize long-term defense programs, noting that “a certain degree of preparation for war is not only indispensable to avert disasters in the onset, but affords also security for the continuance of the peace.”

The War of 1812 gave the young nation a lasting appreciation for the role of military strength in preserving the liberty of its citizens. The war might have continued to the utter ruin of the country and possibly the loss of American independence—certainly the destruction of American prosperity. Despite hopes to the contrary, the military disasters of this war made it clear that the U.S. could not rely on its geography as a national defense nor on strictly defensive armaments and troops; America would have to maintain an increased standing army and construct a blue-water navy, capable of both offensive and defensive action on a large scale. Most Americans recognized this fact and committed themselves to a stronger military. In the following decades, average federal defense spending remained much higher, as Congress and the American people kept in mind the unacceptable cost of failing to provide for the common defense of the United States.

It’s a lesson today’s Americans would do well to keep in mind.