How did we get the United States national anthem?

In September 1814, the United States and Great Britain were in the midst of fighting What is known as the War of 1812. The British had taken over Washington, D.C., and planned to attack Baltimore, Maryland. A few American citizens, including a lawyer and poet named Francis Scott Key, approached the British fleet, which was anchored in Chesapeake Bay, to request the release of an American who had been taken prisoner. The British agreed to let the prisoner and the others return to American shores, but only after the British were done attacking Fort McHenry, Which was defending Baltimore. Throughout the night of September 13–14, Key heard the explosions of the battle, anxiously awaiting morning to see whether the Americans had won the battle. In the early morning light, Key could see that Fort McHenry’s enormous American flag was still waving, indicating that the Americans had been triumphant.

Relieved and inspired by the sight, Key composed a poem called “Defence of Fort M’Henry.” Its opening lines recalled his first glimpse of the flag that morning: “Oh, say can you see, by the dawn’s early light / What so proudly we hailed at the twilight’s last gleaming?” Key may have had a popular tune in mind when writing the poem. That tune, called “To Anacreon in Heaven,” had been an English drinking song, but it soon became linked with Key’s poem, and the title of the new song became “The Star-Spangled Banner.” “The Star-Spangled Banner” (which actually has four verses, though usually only the first is sung) spread quickly throughout the country and became extremely popular. It was played at important ceremonies and military functions for many years before being officially declared the national anthem by Congress in 1931.