<P> On September 3, 1814, following the Burning of Washington and the Raid on Alexandria, Francis Scott Key and John Stuart Skinner set sail from Baltimore aboard the ship HMS Minden, flying a flag of truce on a mission approved by President James Madison . Their objective was to secure an exchange of prisoners, one of whom was Dr. William Beanes, the elderly and popular town physician of Upper Marlboro and a friend of Key's who had been captured in his home . Beanes was accused of aiding the arrest of British soldiers . Key and Skinner boarded the British flagship HMS Tonnant on September 7 and spoke with Major General Robert Ross and Vice Admiral Alexander Cochrane over dinner while the two officers discussed war plans . At first, Ross and Cochrane refused to release Beanes but relented after Key and Skinner showed them letters written by wounded British prisoners praising Beanes and other Americans for their kind treatment . </P> <P> Because Key and Skinner had heard details of the plans for the attack on Baltimore, they were held captive until after the battle, first aboard HMS Surprise and later back on HMS Minden . After the bombardment, certain British gunboats attempted to slip past the fort and effect a landing in a cove to the west of it, but they were turned away by fire from nearby Fort Covington, the city's last line of defense . </P> <P> During the rainy night, Key had witnessed the bombardment and observed that the fort's smaller "storm flag" continued to fly, but once the shell and Congreve rocket barrage had stopped, he would not know how the battle had turned out until dawn . On the morning of September 14, the storm flag had been lowered and the larger flag had been raised . </P> <P> During the bombardment, HMS Terror and HMS Meteor provided some of the "bombs bursting in air". </P>

Where was the star spangled banner written and under what conditions