Francis Scott Key wrote the words to it in 1814 after seeing British ships attacking Fort McHenry in Baltimore , Maryland during the War of 1812 .
The lyrics come from `` Defense of Fort McHenry '' , a poem written in 1814 by the 35-year-old lawyer and amateur poet , Francis Scott Key , after witnessing the bombardment of Fort McHenry by the British Royal Navy ships in Chesapeake Bay during the Battle of Fort McHenry in the War of 1812 .