The history of "The Star-Spangled Banner" centers around the Battle of Baltimore, a British attack on Fort McHenry in Baltimore Harbor. Francis Scott Key, an American lawyer, penned the words on September 14, 1814, after the 25-hour battle ended and he saw the American flag, not the flag of Britain, flying in victory.
A week before the Battle of Baltimore, Francis Scott Key boarded a British flagship in the Chesapeake Bay in an effort to convince soldiers to release his friend, who had been arrested by the British. The soldiers agreed, but because Key knew of the British plan to attack Baltimore, the British released him and his friend back to his ship under constant guarding and scrutiny.
On September 13, 1814, Key, still under guard, witnessed the onslaught of missiles, bullets and shells onto Fort McHenry. The battle continued for so long that Key began to see only red in the sky, and because the British made such a large-scale attack, he was certain of their victory. When the smoke began to clear in the early morning hours, he witnessed the American flag flying over Fort McHenry, and began chronicling his reaction.
Key set his writing to the tune of a popular British song, "The Anacreontic Song"/"To Anacreon In Heaven," written by John Stafford Smith. Key's brother-in-law, a Fort McHenry militia commander, distributed it under the title " Defence of Fort M'Henry." The Baltimore Patriot newspaper printed the song, which circulated in publications across the country within weeks. Renamed "The Star-Spangled Banner," it was officially used by the United States Navy in 1889 and by President Woodrow Wilson in 1916. "The Star-Spangled Banner" became the national anthem on March 3, 1931, under President Herbert Hoover.