"The Star-Spangled Banner" has a very specific setting: the battle of Fort McHenry during the War of 1812. Even more specifically, it tells the story of the British naval bombardment of Fort McHenry between the mornings of September 13 and 14, 1814.
The fort had been built to protect Baltimore shortly after the American Revolution. Shaped like a five-pointed star, surrounded by a dry moat, and situated on a small peninsula that jutted into the harbor, the fort was designed to protect the city from a naval attack up the Chesapeake.
Francis Scott Key kept a concerned watch on the fort from the deck of the HMS Minden. The ship had been built in the British shipyards of Bombay, India, and was seeing its first action during the war against America. Its 74 guns fired a steady stream of shells against the vulnerable American fort.
The battle occurred at a pivotal moment in the war. Just three weeks earlier, British forces had captured and burned the nation's capital at Washington, D.C. Betrayed by poor intelligence and defended, primarily, by poorly trained militia, the city fell with hardly a shot fired in its defense. The sacking of Washington, D.C. was a humiliating blow to the American cause. From the beginning, the Federalist-dominated New England states had opposed the war. Since then, escalating costs and battlefield defeats had strengthened this opposition. Now, with the capital in ruins, many urged surrender or negotiation.
The victory at Fort McHenry immediately reversed the national mood. New Englanders still opposed the war, but supporters in the South and West were revitalized by the victory. It was this broader significance of the battle that explains the song's immediate popularity. It was published locally in Baltimore in September. In October it was performed for the first time, and in November the song was printed in a national magazine.