Francis Scott Key wrote "Defence of Fort M'Henry" (September 1814) after witnessing the British bombardment of Fort McHenry, Baltimore, during the War of 1812.
Key verses (4 total; usually only 1st sung):
O say can you see, by the dawn's early light,
What so proudly we hailed at the twilight's last gleaming...
O say does that star-spangled banner yet wave
O'er the land of the free and the home of the brave?
Key was a lawyer/amateur poet on a truce ship; the flag's survival inspired him.