Baltimore’s Fort McHenry is the location of 200th- anniversary celebrations for the “Star-Spangled Banner,” whose lyrics were written by Francis Scott Key in September 1814. (Linda Davidson/The Washington Post)

The firing had stopped more than an hour earlier, after an all night shootout in the rain between 16 British warships and the rugged American citadel of Fort McHenry.

But at 9 a.m. Sept. 14, 1814, amid the mist and lingering smoke, it was not clear who had won. Would the British now barge into this metropolis of 50,000, burning and looting as they had done in Washington the month before?

Was this fledgling collection of “united states” for real or just a dream?

As the Georgetown lawyer, devout Episcopalian and amateur poet Francis Scott Key peered into the murk, he anguished over his country’s fate during the War of 1812. Suddenly, a gigantic red, white and blue ensign with 15 huge stars and two-foot-wide stripes was hauled up the fort’s flagpole.

Key, 35, was jubilant and inspired to write. Yet he would end the first stanza of his stirring new song with a question mark:

Historical reinactment is part of the national anthem’s 200th birthday celebration. (Linda Davidson/The Washington Post)

O say does that star-spangled banner

yet wave

O’er the land of the free and the home

of the brave?

This weekend, Baltimore and the nation mark the 200th anniversary of the national anthem, which still opens with Key’s cosmic question.

Anthem festivities at the fort are already underway, and President Obama has scheduled a private visit Friday.

Events are set to culminate there Saturday with an air show by the Navy’s Blue Angels flight team, an evening speech by Vice President Biden, and a gala music and fireworks program.

A handwritten copy of what is now known as the “Star-Spangled Banner,” at the Library of Congress. Francis Scott Key wrote the lyrics after witnessing the British assault on Baltimore in 1814. (J. Lawler Duggan/For The Washington Post)

Sunday’s schedule includes a speech by former secretary of state Colin L. Powell, a Blue Angels encore, and a 9 a.m. reenactment of the dramatic flag-raising that prompted Key’s lyric outburst.

“It’s the only national anthem that exists that ends [as usually sung] in a question mark,” said Loras John Schissel, a music specialist at the Library of Congress, long the center of anthem scholarship.

“I think that’s so appropriate for this big thing we call the experiment in Democracy,” he said. “Because it’s always unfinished. It’s always a day-to-day contribution that we all make to make sure that it goes on, that it’s a success.”

“The way Key writes the poem . . . he’s asking: ‘Is the flag still flying? Are we still a country? Did the British kick our butts? Are we still in existence?’ ” Schissel said. “He actually answers that.”

What is that which the breeze, o’er the towering steep,

As it fitfully blows, half conceals, half discloses?

. . .’Tis the star-spangled banner! O long may it wave

O’er the land of the free and the home of the brave!

In September 1814, Key was headed to Baltimore to negotiate the release of a friend, who had been seized by the British, when he, too, was detained.

(The United States had declared war on Britain two years earlier over aggressive British naval policies and support for Native Americans.)

Key wound up watching the assault while under Royal Marine guard aboard an American truce ship, according to Steve Vogel, author of the book, “Through the Perilous Fight: Six Weeks That Saved the Nation.”

Having pillaged Washington and burned the White House, the British army and navy were intent on sacking Baltimore, a much larger and more important city. While its army closed in from the east, its navy hammered Fort McHenry, which guarded the entrance to the inner harbor, on Sept. 13 and 14.

But an American sharpshooter killed a British general, and the British army found itself outnumbered and facing formidable land defenses outside Baltimore.

The navy, meanwhile, encountered terrible weather and a defiant Fort McHenry, bristling with heavy guns and a garrison of about 1,200 men, National Park Service Ranger Jim Bailey said.

The slugfest went on for 25 hours.

“The portals of hell appeared to have been thrown open — the earth and air, nay all the elements, seem to have been combined for the destruction of man,” an eyewitness wrote, according to Vogel.

Key had dabbled in writing patriotic lyrics before.

In 1805, he wrote “When the Warrior Returns From the Battle Afar,” in honor of a recent U.S. Navy victory over North African pirates. The lyric contained such lines as “by the light of the star-spangled flag of our nation.”

And it ended:

Where, mix’d with the olive, the laurel shall wave,

And form a bright wreath for the brows of the brave.

Key set the words to a pop melody of the time, “To Anacreon in Heaven,” which had started out years before as a jaunty ode to a Greek poet.

Now, as he anguished in the rain and shells exploded over Fort McHenry, the same melody came to him, perhaps fragments from his earlier song and powerful new lyrics.

They “were born out of extreme tribulation,” said Schissel, of the Library of Congress. “It was not him sitting at home. . . . This is written in real time.”

“You can imagine in the morning there . . . and seeing that huge red white and blue thing go up the pole, and realizing in that split second: ‘It worked. We’re still here.’ ”

Key, who was later released by his captors, called his song the “Defence of Fort M’Henry.”

But canny music publishers saw the need for a jazzier title and began marketing it as the “Star Spangled Banner.” Schissel said, “It’s a great title.”

At Fort McHenry on Tuesday, Park Ranger Bailey was decked out in the uniform, epaulettes and big feathered hat of Maj. George Armistead, the fort’s commanding officer in 1814.

He swaggered about as Armistead, issuing orders as thousands of schoolchildren watched on a Jumbotron screen. He told how he had ordered the fabrication of a huge “garrison flag” — 30 by 42 feet — to inspire his men.

He directed the firing of a reproduction of one of the fort’s 21 / 2- ton guns, which could fling a 24-pound iron ball a mile and a half.

And as he spoke, a huge banner, the same size as the original, flew from the fort’s flagpole and snapped in the damp breeze that blew off the water.

Juliet Eilperin contributed to this report.