<P> "The Star - Spangled Banner" is the national anthem of the United States of America . The lyrics come from "Defence of Fort M'Henry", a poem written on September 14, 1814, by the 35 - year - old lawyer and amateur poet Francis Scott Key after witnessing the bombardment of Fort McHenry by British ships of the Royal Navy in Baltimore Harbor during the Battle of Baltimore in the War of 1812 . Key was inspired by the large American flag, the Star - Spangled Banner, flying triumphantly above the fort during the American victory . </P> <P> The poem was set to the tune of a popular British song written by John Stafford Smith for the Anacreontic Society, a men's social club in London . "To Anacreon in Heaven" (or "The Anacreontic Song"), with various lyrics, was already popular in the United States . Set to Key's poem and renamed "The Star - Spangled Banner", it soon became a well - known American patriotic song . With a range of one octave and one fifth (a semitone more than an octave and a half), it is known for being difficult to sing . Although the poem has four stanzas, only the first is commonly sung today . </P> <P> "The Star - Spangled Banner" was recognized for official use by the United States Navy in 1889, and by U.S. President Woodrow Wilson in 1916, and was made the national anthem by a congressional resolution on March 3, 1931 (46 Stat. 1508, codified at 36 U.S.C. § 301), which was signed by President Herbert Hoover . </P> <P> Before 1931, other songs served as the hymns of American officialdom . "Hail, Columbia" served this purpose at official functions for most of the 19th century . "My Country,' Tis of Thee", whose melody is identical to "God Save the Queen", the British national anthem, also served as a de facto anthem . Following the War of 1812 and subsequent American wars, other songs emerged to compete for popularity at public events, among them "The Star - Spangled Banner", as well as "America the Beautiful". </P>

When did the star spangle banner become the national anthem