Francis Scott Key was a gifted amateur poet and hymnist. Inspired by the sight of the American flag flying over Fort McHenry the morning after the bombardment, he scribbled the initial notes for his poem on the back of a letter. Back in Baltimore, he copied the four verses onto paper, probably making more than one copy. The next morning someone printed the poem as a broadside. Shortly afterward two Baltimore newspapers published it, and by mid-October it had appeared in at least 17 other papers in cities up and down the east coast.
The melody to which Francis Scott Key intended his poem to be sung was the popular English tune known as "To Anacreon in Heaven." Written about 1775 by John Stafford Smith, the tune was originally the "constitutional song" of the Anacreontic Society, a gentlemen's music club in London named after the 6th-century B.C.E. Greek poet Anacreon. It became extremely popular in America, where it was used to accompany a number of verses, including the patriotic song called "Adams and Liberty," before 1814. Key himself used the tune for his 1805 poem "When the Warrior Returns from the Battle Afar."
"O Say Can You See?"
Defence of Fort McHenry
The annexed song was composed under the following circumstances -
A gentleman had left Baltimore, in a flag of truce for the purpose of getting released from the British fleet, a friend of his who had been captured at Marlborough.--He went as far as the mouth of the Patuxent, and was not permitted to return lest the intended attack on Baltimore should be disclosed. He was therefore brought up the Bay to the mouth of the Patapsco, where the flag vessel was kept under the guns of a frigate, and he was compelled to witness the bombardment of Fort McHenry, which the Admiral had boasted that he would carry in a few hours, and that the city must fall. He watched the flag at the Fort through the whole day with an anxiety that can be better felt than described, until the night prevented him from seeing it. In the night he watched the Bomb Shells, and at early dawn his eye was again greeted by the proudly waving flag of his country.
Tune - Anacreon in Heaven.
O! say can you see by the dawn's early light,
What so proudly we hailed at the twilight's last gleaming,
Whose broad stripes and bright stars through the perilous fight,
O'er the ramparts we watch'd, were so gallantly streaming?
And the Rockets' red glare, the Bombs bursting in air,
Gave proof through the night that our Flag was still there;
O! say does that star-spangled Banner yet wave,
O'er the Land of the free, and the home of the brave?
On the shore dimly seen through the mists of the deep,
Where the foe's haughty host in dread silence reposes,
What is that which the breeze, o'er the towering steep,
As it fitfully blows, half conceals, half discloses?
Now it catches the gleam of the morning's first beam,
In full glory reflected now shines in the stream,
'Tis the star-spangled banner, O! long may it wave
O'er the land of the free and the home of the brave.
And where is that band who so vauntingly swore
That the havoc of war and the battle's confusion,
A home and a country, shall leave us no more?
Their blood has washed out their foul footsteps pollution.
No refuge could save the hireling and slave,
From the terror of flight or the gloom of the grave,
And the star-spangled banner in triumph doth wave,
O'er the Land of the Free, and the Home of the Brave.
O! thus be it ever when freemen shall stand,
Between their lov'd home, and the war's desolation,
Blest with vict'ry and peace, may the Heav'n rescued land,
Praise the Power that hath made and preserv'd us a nation!
Then conquer we must, when our cause it is just,
And this be our motto--"In God is our Trust;"
And the star-spangled Banner in triumph shall wave,
O'er the Land of the Free, and the Home of the Brave.
This is the first known printing of Key's poem. Called a broadside, it was probably printed in Baltimore on Sept. 17, 1814. It once belonged to Judge Joseph H. Nicholson, who was married to Key's wife's sister. 
Courtesy Maryland Historical Society