The article below claims that Francis Scott Key borrowed the tune “To Anacreon in Heaven” - video of that tune is linked below.
‘Star-Spangled Banner’: Anthem was once a song of drinking and sex
The words of To Anacreon in Heaven, the song that Francis Scott Key borrowed for the melody of ‘The Star-Spangled Banner,’
The Anacreon Song
http://www.youtube.com/watch?v=ydAIdVKv84g
Which seems to have been a favorite tavern song of the day, so that writing patriotic lyrics to the tune would be a vehicle to make the lyrics more popular.