The San Jose Sharks stand for the national anthem prior...

The San Jose Sharks stand for the national anthem prior to a a preseason game against the Anaheim Ducks at Honda Center on Sept. 28, 2017 in Anaheim, California. Credit: Getty Images / Sean M. Haffey

For decades, it’s been an integral part of the American sporting experience. Before Super Bowls, before boxing matches, before high school soccer games, we are supposed to stand, remove our hats and sing the national anthem.

When it comes to sports, we’re required to stand up before we sit down. Yet, the question is: Why? Why is “The Star-Spangled Banner’’ played before almost every sporting event, if we don’t play the anthem before a movie, or a concert or in a situation where it might actually make sense, like a joint session of Congress?

The marriage between sports and patriotism in the United States as embodied in playing of the anthem is a unique and complicated one. Today the anthem remains at the center of an intense national debate, with some interpreting the song’s meaning as an unassailable sign of respect for the military and others seeing it as reflecting the totality of the American experience, both the good and bad.

The United States and Canada, which shares many of our sports leagues, are alone when it comes to the custom of playing the anthem. They don’t sing “God Save the Queen” before English Premier League matches. Nor do they sing “Jana Gana Mana” before cricket matches in India, though by law it must be played before the screening of movies.

“We’re a very patriotic country and we’re different from the rest of the world in that respect,” said Marc Ferris, author of “Star-Spangled Banner: The Unlikely Story of America’s National Anthem.’’ “It’s always been a very politicized song that has strong ties to the military, and sports is kind of like a sanitized war in a way.”

The song, which became the national anthem in 1931, is an unlikely candidate to be beloved by the sporting masses: It has a melody that few Americans can sing without difficulty and is about a war that few Americans know much about. Written as a poem by Francis Scott Key about a battle in the War of 1812, its first documented performance as a song at a sporting event was at a baseball game in Brooklyn in 1862. The song was played sporadically for the next 75 years, with its most notable appearance being in the World Series of 1918, when the country was in the thick of World War I.

The lack of public-address systems meant that team owners had to hire expensive bands to play the song, which Ferris said played a large part in limiting its performance to special occasions. Technology, however, and a new war changed everything in the 1940s.

Whitney Houston delivered a prerecorded version of the national anthem...

Whitney Houston delivered a prerecorded version of the national anthem before the Super Bowl in Tampa on Jan. 27, 1991, perhaps the most famous rendition toward the end of the first Gulf War. Houston sang live but into a dead microphone. Credit: AP / Al Messerschmidt Archive

“In World War II, it was heard everywhere,” Ferris said. “Before movies, before the opera, before plays, before meetings, before bond drives, before village board meetings. It also started to be all over the place in sports, as well, primarily because there was amplification. You could get one person to sing it over the mike or play a recording.”

Days after Japan surrendered, NFL commissioner Elmer Layden called for “The Star-Spangled Banner’’ to be played at all NFL games, stating, “The national anthem should be as much a part of every game as the kickoff.” And so, while the anthem began to disappear from the movie theater and the opera house, it became an integral part of the sporting experience.

The NBA has played it before every game since the league’s inception in 1946. The NHL has also played it since 1946, though it has allowed “God Bless America’’ to be used as a substitute. Oddly, there were a few holdouts in baseball. The Cubs didn’t start playing the anthem on an everyday basis until 1967 because the owner thought playing it every day cheapened the song.

Currently, the UFC is the only American-based professional sports organization that does not play the anthem before contests. President Dana White told Sports Illustrated that the UFC supports the military, but decided not to play the anthem early on after it messed up the timing of a pay-per-view event when all the matches went the distance. “It’s a jinx thing for me,” White said.

That decision may save White a lot of the headaches that other leagues are experiencing. A little more than a year after former 49ers quarterback Colin Kaepernick launched a protest movement by kneeling during the anthem to call attention to social and racial injustice, anthem protests — and fan reaction to them led by President Donald Trump’s call to fire the protesters — are spreading throughout the sporting world.

Chants of “USA, USA” erupted at the Bears-Packers game in Green Bay on Thursday night as players from both teams stood with arms linked before kickoff. The NBA, which — unlike the NFL — has a rule that requires teams to stand during the anthem, opens its season in two weeks and many players have already been outspoken about the issue.

Said Ferris: “This all just proves my theory that it’s the most controversial song in U.S. history. It’s a symbol. You can look at the United States and say we’re an oppressive country. You can look at the United States and say we’ve come the furthest as far as granting our people’s rights. There’s so many ways you can look at our history, and ‘The Star-Spangled Banner’ is the symbol of that.”

A symbol that remains tied to sports.