The poem, originally titled "The Defence of Fort McHenry," was written after Key witnessed the Maryland fort being bombarded by the British during the War of 1812.
Key was inspired by the sight of a lone U.S. flag still flying over Fort McHenry at daybreak, as reflected in the now-famous words of the "Star-Spangled Banner":
"And the rocket's red glare, the bombs bursting in air, Gave proof through the night that our flag was still there."