Today, the United States of America commemorates 238 years of independence from the British—but an approaching bicentennial serves as a reminder that the struggle to establish sovereignty was only beginning when the Declaration of Independence was written. During the summer of 1814, the United States was in the full throes of what historians have long considered a “second war of independence.” The turning point of that war would come at the Battle of Baltimore, known to most Americans today as the inspiration for the national anthem, “The Star-Spangled Banner.”

The invading British had just burned the White House and plundered the port of Alexandria. On August 27, the Baltimore Patriot printed a letter from President James Madison, who had recently fled from the burning capital:

“On an occasion which appeals so forcibly to the proud feelings and patriotic devotion of the American people, none will forget what they owe to themselves; what they owe to their country and the high destinies which await it; what to the glory acquired by their fathers, in establishing the independence which is now to be maintained by their sons, with the augmented strength and resources with which time and Heaven have blessed them.”

The letter was addressed to the whole nation, but its exhortation to preserve the young nation’s independence was keenly felt in the notoriously anti-British city of Baltimore. The city was then known for its privateers, who raided British ships’ merchandise, as well as for a series of anti-British riots during which mobs burned the offices of anti-war newspapers. Baltimore was also of great strategic importance as a busy port that connected several East Coast cities by land and sea. The city’s residents were perhaps uniquely prepared for such an invasion due to their strong local tradition of civic self-defense. After the riots, local elites had recognized the authorities’ failure to keep the crowds under control and independently organized patrols of armed citizens to assist in expanding the city’s defensive resources.

But the events of the summer of 1814 pushed the city to formalize their efforts more strongly. After news of the fall of Washington, Baltimoreans set up a Committee of Vigilance and Safety comprised of the existing Maryland militia as well as civilians who served as volunteers on a rotating night patrol. Besides the night watch, the Committee was also responsible for raising funds for the local war effort, which generally took the form of donating at each prominent community center (usually a local tavern). A prescient Washingtonian wrote to Baltimore’s American and Commercial Daily Advertiser: “If the British visit Baltimore I have no doubt you will receive them in American style—we are disgraced.”

The local militia was particularly focused on unity in the face of the national military’s failure. The biggest blow to military success was the strategic blunder made by the Secretary of War, John Armstrong, who was thoroughly convinced that the British would not attack Washington. He saw the city as strategically insignificant, so he failed to prepare for its defense, which ended up drawing military resources to the region in a scrambled last-minute effort. Armstrong resigned after the defeat at Washington, but the local militia were already prepared to count on themselves for the most part. When his resignation letter made it to Baltimore, along with a full account of the disastrous battle, publishers refrained from comment and blame games. Invoking patriotism, the editor of the Baltimore Patriot proclaimed: “An enquiry must be made–when the nation is saved.” This restrained attitude continued through the city’s preparations for war, as the staff printed assurances of the city’s proper defense without giving particulars for fear of over-informing the enemy.

Morale quickly increased as the British made their way back north. A Revolutionary War veteran wrote in to the Baltimore Patriot encouraging the militia: “Be ready to suffer every thing, to attempt every thing in submission to Providence.” It ran alongside an account of the Maryland militia’s bravery in repulsing a surprise British attack in the Battle of Caulk’s Field, just a few miles across the river from Baltimore. The militia’s ability to fend off the British without any national military aid from the Army was a particularly hopeful sign for the Baltimoreans, who were preparing to engage an empire with a force of mainly armed citizens rather than professional soldiers.

The local militia took the brunt of the British force at the initial land engagement when the battle began on September 12 at North Point outside Baltimore. Though the Marylanders ended up retreating, they did major damage to the British forces, killing one of their commanders and scattering the remaining units into confusion. This allowed the national military, mainly the Army infantry under Major George Armistead, time to mount their famous defense of Fort McHenry against the bombardment of the Royal Navy.

“The Star-Spangled Banner” may only describe the more picturesque battle at sea, but the story of the song itself tells the full tale. Francis Scott Key, a Georgetown lawyer on a mercy mission to secure the release of an imprisoned American doctor, watched the Army defend the fort while detained on a British ship. He began scribbling away his famous poem there, but he did not finish it until he arrived at the tavern where he would stay the night.

The tavern, called the Indian Queen and maintained by hotelier John Gadsby, had been the central gathering point for the appointment of patrols after the riots. It had hosted the militia as they trained over the course of the war. It had been a neighborhood headquarters for the Committee of Vigilance and Safety. It was the perfect manifestation of the local effort that saved Baltimore behind the scenes of Key’s star-spangled tale. The tavern is a reminder that in Key’s famous words, it was not just a country, but a city, that was “the home of the brave.”