Historians don't agree where the sports-anthem tie began, but everyone acknowledges that it started with baseball. Some say that “The Star-Spangled Banner” was performed as early as 1897 during opening day in Philadelphia while others believe the connection was made during the first game of the 1918 World Series.
Whatever the case, the ritual of having the anthem performed at games seemed to gain steam at that World Series. Throughout the United States' participation in World War I, patriotic songs were often played during Major League Baseball games, but when the band broke into “The Star-Spangled Banner” during the seventh inning stretch during that first game in Chicago, the song struck a chord. Players turned and faced the flagpole. Fans sang along, then applauded at the end. The reaction caused the band to play the song the next two games, and when the series moved to Boston, the band there continued the tradition.
Even though “The Star-Spangled Banner” was played at baseball games on special occasions such as opening day or holidays after that, it didn't become a pregame staple until two decades later. Huge displays of patriotism became the norm at baseball games during World War II, and because the song had been deemed the national anthem by congressional resolution in 1931, it was played before games throughout the war.
The ceremony eventually became part of every big-league game, and before long, it spread to other sports.