During the War of 1812, Key and British Prisoner Exchange Agent Colonel John Stuart Skinner dined aboard HMS Tonnant as the guests of Vice Admiral Alexander Cochrane, Rear Admiral George Cockburn, and Major General Robert Ross.
Skinner and Key were there to negotiate the release of prisoners, one of whom was William Beanes, a resident of Upper Marlboro, Maryland, who had been arrested after jailing British troops who were taking food from local farms.
Skinner, Key, and Beanes were not allowed to return to their own sloop because they had become familiar with the strength and position of the British units and their intention to launch an attack upon Baltimore, and Key was unable to do anything but watch the bombarding of the American forces at Fort McHenry during the Battle of Baltimore on the night of September 13–14, 1814.

At dawn, Key was able to see an American flag waving, and he later wrote a poem about his experience entitled "Defence of Fort M'Henry" which was published in William Pechin's American and Commercial Daily Advertiser on September 21, 1814.
He took it to music publisher Thomas Carr, who adapted it to the rhythms of composer John Stafford Smith's "To Anacreon in Heaven", a popular tune that Key had already used as a setting for his 1805 song "When the Warrior Returns", celebrating American heroes of the First Barbary War.
It was somewhat difficult to sing, yet it became increasingly popular, competing with "Hail, Columbia" (1796) as the de facto national anthem by the time of the Mexican–American War and the American Civil War.
The song was finally adopted as the American national anthem more than a century after its first publication, first by an Executive Order from President Woodrow Wilson in 1916, and then by a Congressional resolution in 1931 signed by President Herbert Hoover.

The third stanza of the Star-Spangled Banner makes disparaging mention of blacks and demonstrates Key's opinion of their seeking freedom at the time by escaping to the British, who promised them freedom from American enslavement.
During the War of 1812, Key and British Prisoner Exchange Agent Colonel John Stuart Skinner dined aboard HMS Tonnant as the guests of Vice Admiral Alexander Cochrane, Rear Admiral George Cockburn, and Major General Robert Ross. Skinner and Key were there to negotiate the release of prisoners, one of whom was William Beanes, a resident of Upper Marlboro, Maryland, who had been arrested after jailing British troops who were taking food from local farms. Skinner, Key, and Beanes were not allowed to return to their own sloop because they had become familiar with the strength and position of the British units and their intention to launch an attack upon Baltimore, and Key was unable to do anything but watch the bombarding of the American forces at Fort McHenry during the Battle of Baltimore on the night of September 13–14, 1814.
At dawn, Key was able to see an American flag waving, and he later wrote a poem about his experience entitled "Defence of Fort M'Henry" which was published in William Pechin's American and Commercial Daily Advertiser on September 21, 1814. He took it to music publisher Thomas Carr, who adapted it to the rhythms of composer John Stafford Smith's "To Anacreon in Heaven", a popular tune that Key had already used as a setting for his 1805 song "When the Warrior Returns", celebrating American heroes of the First Barbary War. It was somewhat difficult to sing, yet it became increasingly popular, competing with "Hail, Columbia" (1796) as the de facto national anthem by the time of the Mexican–American War and the American Civil War. The song was finally adopted as the American national anthem more than a century after its first publication, first by an Executive Order from President Woodrow Wilson in 1916, and then by a Congressional resolution in 1931 signed by President Herbert Hoover.
The third stanza of the Star-Spangled Banner makes disparaging mention of blacks and demonstrates Key's opinion of their seeking freedom at the time by escaping to the British, who promised them freedom from American enslavement.
Francis Scott Key