Key wrote the poem, originally titled "Defence of Fort McHenry," after witnessing the bombardment of Fort McHenry by the British during the Battle of Baltimore in September 1814. He was inspired by the sight of the American flag still flying proudly over the fort despite the heavy shelling.
"The Star-Spangled Banner" was later set to music and became the national anthem of the United States in 1931.