In a turning point in the War of 1812, the British fail to capture Baltimore. During the battle, Francis Scott Key composes his poem "Defence of Fort McHenry", which is later set to music and becomes the United States' national anthem.

"The Star-Spangled Banner" is the national anthem of the United States. The lyrics come from the "Defence of Fort M'Henry", a poem written on September 14, 1814, by 35-year-old lawyer and amateur poet Francis Scott Key after witnessing the bombardment of Fort McHenry by British ships of the Royal Navy in Outer Baltimore Harbor in the Patapsco River during the Battle of Baltimore in the War of 1812. Key was inspired by the large U.S. flag, with 15 stars and 15 stripes, known as the Star-Spangled Banner, flying triumphantly above the fort during the U.S. victory.

The poem was set to the tune of a popular British song written by John Stafford Smith for the Anacreontic Society, a men's social club in London. "To Anacreon in Heaven" (or "The Anacreontic Song"), with various lyrics, was already popular in the United States. This setting, renamed "The Star-Spangled Banner", soon became a well-known U.S. patriotic song. With a range of 19 semitones, it is known for being very difficult to sing. Although the poem has four stanzas, only the first is commonly sung today.

"The Star-Spangled Banner" was first recognized for official use by the U.S. Navy in 1889. In 1931, the U.S. Congress passed a joint resolution (46 Stat. 1508) making the song the official national anthem of the United States, which President Herbert Hoover signed into law. The resolution is now codified at 36 U.S.C. § 301(a).

Baltimore ( BAWL-tim-or, locally: BAWL-mər) is the most populous city in the U.S. state of Maryland, as well as the 30th most populous city in the United States, with a population of 585,708 in 2020. Baltimore was designated an independent city by the Constitution of Maryland in 1851, and today is the largest independent city in the United States. As of 2017, the population of the Baltimore metropolitan area was estimated to be around 2.8 million, making it the 21st largest metropolitan area in the country. Baltimore is located about 40 miles (64 km) northeast of Washington, D.C., making it a principal city in the Washington–Baltimore combined statistical area (CSA), the third-largest CSA in the nation, with a calculated 2018 population of 9,797,063.Prior to European colonization, the Baltimore region was used as hunting grounds by the Susquehannock Native Americans, who were primarily settled further north than where the city was later built. Colonists from the Province of Maryland established the Port of Baltimore in 1706 to support the tobacco trade with Europe, and established the Town of Baltimore in 1729. The first printing press and newspapers were introduced to Baltimore by Nicholas Hasselbach and William Goddard respectively, in the mid-18th century.

The Battle of Baltimore was a pivotal engagement during the War of 1812, culminating in the failed British bombardment of Fort McHenry, during which Francis Scott Key wrote a poem that would become "The Star-Spangled Banner", which was eventually designated as the American national anthem in 1931. During the Pratt Street Riot of 1861, the city was the site of some of the earliest violence associated with the American Civil War.

The Baltimore and Ohio Railroad, the oldest railroad in the United States, was built in 1830 and cemented Baltimore's status as a major transportation hub, giving producers in the Midwest and Appalachia access to the city's port. Baltimore's Inner Harbor was once the second leading port of entry for immigrants to the United States. In addition, Baltimore was a major manufacturing center. After a decline in major manufacturing, heavy industry, and restructuring of the rail industry, Baltimore has shifted to a service-oriented economy. Johns Hopkins Hospital and Johns Hopkins University are the city's top two employers. Baltimore and its surrounding region are home to the headquarters of a number of major organizations and government agencies, including the NAACP, ABET, the National Federation of the Blind, Catholic Relief Services, the Centers for Medicare & Medicaid Services, and the Social Security Administration.

Many of Baltimore's neighborhoods have rich histories. The city is home to some of the earliest National Register Historic Districts in the nation, including Fell's Point, Federal Hill, and Mount Vernon. These were added to the National Register between 1969 and 1971, soon after historic preservation legislation was passed. Baltimore has more public statues and monuments per capita than any other city in the country. Nearly one third of the city's buildings (over 65,000) are designated as historic in the National Register, which is more than any other U.S. city.