During the battle, Key witnessed the bombardment of Fort McHenry by British ships. He was held on a British ship as a prisoner of war but was released after the battle. During the night, he saw the large American flag still flying over the fort despite the intense shelling, which inspired him to write the poem.
Key's original manuscript was published in a Baltimore newspaper shortly after the battle under the title "Defence of Fort M'Henry." The poem quickly gained popularity and was set to music by several composers. The most well-known version is the melody composed by John Stafford Smith in 1814, which was originally titled "To Anacreon in Heaven" and was used by an amateur singing club called the Anacreontic Society.
It was not until 1931 that "The Star-Spangled Banner" was officially designated as the National Anthem of the United States by an Act of Congress. Today, it is a cherished symbol of American patriotism and pride, strongly tied to the nation's history and the sacrifices made by its citizens during the War of 1812 and other conflicts.