The text is written in 1814 by the 35-year-old poet and lawyer Francis Scott Key after he witnessed the bombardment of Fort McHenry in Baltimore during the war of 1812. Key was aboard a British warship to free a friend who was accused of protecting British deserters. The British commanders agreed to release the two men, but they still were held overnight for security reasons while the British fleet assaulted the fort.
The next day Key wrote a poem with the title The Defense of Fort McHenry. The music to which it was put was a popular song of the time (to Anacreon in Heaven), written around1800 by John Stafford Smith.
It was adopted as the national anthem of the United States on 3 March 1931. In most cases, only the first verse Sung. The song is hard to sing, the breath control while singing is tricky because the text no natural breathing space offers. Gore Vidal calls it a "musical roller coaster" and explains the American habit to hand while singing on the chest to keep out respiratory distress.