In 1814, the main body of the British invaders passed through Upper Marlboro, Maryland. Many of the officers made their headquarters at the home of Dr. William Beanes, a physician whom the whole town loved. When some of the stragglers from the army began to plunder the house, Dr. Beanes put himself at the head of a small body of citizens and pursued these stragglers. When the British officers heard of this, Dr. Beanes was seized and treated, not with kindness as a prisoner of war, but with great indignity. Key, as an intimate friend of the doctor, and a lawyer, was asked by the townsmen to intercede for the prisoner. When application was made to President Madison for help, he arranged to send Key to the British fleet, under a flag of truce, on a government vessel, in company with John S. Skinner, a government agent.
For a week or ten days no word came from the expedition. The people were alarmed for the safety of Key and his companion.
The bearers of the flag of truce found the fleet at the mouth of the Potomac. They were received courteously until they told their business. The British commander spoke harshly of Dr. Beanes, but fortunately Mr. Skinner had letters from the British officers who had received kindness at the doctor's hands. General Ross finally agreed that, solely as a recognition of this kindness, the prisoner would be released. But he told the Americans that they could not leave the fleet for some days. They were therefore taken to the frigate Surprise, where they were under guard. They understood that an immediate attack on Baltimore was contemplated, and that they were being restrained that they might not warn the city of the plans of the enemy.
That night Fort McHenry was attacked. The Admiral had boasted that the works would be carried in a few hours, and that the city would then fall. So, from the deck of the Surprise, Key and his companion watched and listened anxiously all night. Every time a shell was fired, they waited breathlessly for the explosion they feared might follow. "While the bombardment continued, it was sufficient proof that the fort had not surrendered. But it suddenly ceased some time before day.... They paced the deck for the remainder of the night in fearful suspense.... As soon as it dawned, and before it was light enough to see objects at a distance, their glances were turned to the fort, uncertain what they should see there, the Stars and Stripes, or the flag of the enemy. At length the light came, and they saw that 'our flag was still there.'"
A little later they saw the approach of boats loaded with wounded British soldiers. Then Key took an envelope and wrote many of the lines of the song, and while he was on the boat that carried him to shore he completed the first rough draft. That night, at the hotel, he rewrote the poem. Next day he showed it to Judge Nicholson, who was so delighted with it that the author was encouraged to send it to a printer, by the hand of Captain Benjamin Eades. Captain Eades took the first handbill that came from the press and carried it to the old tavern next the Holliday Street Theatre. There the words were sung for the first time, to the tune "Anacreon in Heaven," the tune Key had indicated on his copy.
Long before the author's death in 1843 the song had won its place in the affections of the people. He wrote many other poems, and some of them have become popular hymns. At the memorial service conducted for him in Christ Church, Cincinnati, by his friend and former pastor, Rev. J. T. Brooke, the congregation was asked to sing Key's own hymn, beginning:
"Lord, with glowing heart I'd praise thee,
For the bliss thy love bestows;
For the pardoning grace that saves me,
And the peace that from it flows.