A near two-century-old copy of “The Star Spangled Banner” sold for $506,500 Friday at Christie’s auction house in Manhattan.

The famed sheet music is one of 11 known first edition copies of Francis Scott Key’s patriotic tune, said to have been written after he witnessed the British naval bombardment of Fort McHenry during the War of 1812.

The iconic manuscript was sold to a telephone bidder, who was not immediately named.

Key, then a young lawyer and amateur poet, is said to have boarded a truce vessel in Chesapeake Bay in an effort to negotiate the release of a detained American doctor, according to documents from the Smithsonian National Museum of American History.

But Key was himself detained overnight by Royal Navy officials to ensure their plans for the assault on the fort were not revealed to its defenders.

His vantage point aboard the British ship is said to have offered sweeping views of the ensuing battle, spanning the night of September 13 to the morning of September 14, 1814.

“By the dawn’s early light,” Key saw that the fort’s flag — torn and singed from near-constant shelling — had remained flying above its walls. The inspiring words later were put to existing music and printed by Baltimore music publisher Thomas Carr.

Carr is said to have rushed to publish the song, leaving first copies with an error in the title. The copy at Christie’s bears that first-edition hallmark, Christie’s spokesman Chris Coover said.

The print reads: “The Star Spangled Banner. A Pariotic Song,” rather than “Patriotic.”

The copy was sold as a part of the auction house’s autumn “Fine Printed Books and Manuscripts including Americana” sale.

It is the only privately owned copy of the first edition, Coover said. The other 10 copies are held by institutions or university libraries.

The copy’s original owner kept the document with 49 other pieces of sheet music in an album used as a song book for family gatherings, according to Coover.

Once purchased for $50, the two-paged copy had been valued between $200,000 and $300,000.

Congress named “The Star Spangled Banner” the country’s national anthem in 1931.

News report from CNN, with Gabi Casanas contributing.