The National Anthem of the United States is the poem "Defense of Fort McHenry," written during the War of 1812 by Francis Scott Key. Some of the wording and imagery came from some previous writings Key had penned years before in a song called "When the Warrior Returns." Key gave no indication he intended on putting his poem to music but his brother-in-law Judge Joseph Nicholson felt the words easily matched the tune of a popular British society club for amateur musicians known as the Anacreontic Society. Their anthem was known as "To Anacreon in Heaven." Although British in origin, this song was very popular even in the United States.

Although frequently referred to as a British "drinking song," it was not intended that way. The anthem for the Anacreontic Society was sung after dinner and business was concluded, as a sort of opening for the more casual and light hearted part of the meetings. Instantly popular, in very short order states were publishing the song and by the latter years of the nineteenth century it was adopted by the military to be played at the raising of the flag as well as on many other official occasions. By the turn of the twentieth century its popularity was soaring and more organizations were playing it in official occasions.

Although a bill was introduced in 1918 to establish it as the national anthem, it wasn't until 1931 the US officially declared "The Star Spangled Banner" our very first national anthem.

More Info: en.m.wikipedia.org