The 5-year-old and his family had traveled thousands of miles to escape. When they finally arrived on U.S. soil, free from the marauders who had burned their house, the boy was placed in a holding pen with his brother and sisters, while immigration officials decided their fate.

From this story, a classic piece of music emerged. The family, fleeing religious persecution in Russia in 1893, was soon reunited and allowed to stay. And that little boy, born Israel Beilin, would grow up to become Irving Berlin. Twenty-five years after emigrating, the same year he became an American citizen, he composed “God Bless America.”

The song, which rings out with special fervor each July 4th, is turning 100 this year, and at a fraught moment in America’s relations with would-be immigrants, it is worth remembering its origins.

Berlin said he first heard the title phrase from his mother, who frequently spoke the words with an emotion he later said “was almost exaltation,” despite their poverty. His daughter Mary Ellin Barrett later wrote that Berlin meant every word: “It was the land he loved. It was his home sweet home. He, the immigrant who had made good, was saying thank you.”

The 30-year-old Berlin, already a successful songwriter, was naturalized as a citizen in February 1918. That May, he began his military service as an Army private at Camp Upton in Yaphank, N.Y., where he was asked to write a soldier show as a fundraiser.

“God Bless America” was originally conceived as the finale for the revue, but Berlin ultimately decided not to include it. It was forgotten for 20 years, until he rediscovered the song and provided a revised version to Kate Smith, who sang it on Nov. 10, 1938, and reprised it weekly.

Rise of Nazism

Berlin’s immigrant success story connected the song, in the period just after its premiere, to a burgeoning public appeal for tolerance in the face of the rise of Nazism in Europe. Berlin led a crowd in “God Bless America” after a speech against bigotry by First Lady Eleanor Roosevelt, in which she warned, “Fear arising from intolerance and injustice constitutes the chief danger to our country.”

The song — written by a Jew who dared to ask God to bless America — inspired anti-Semitic and xenophobic rhetoric aimed at Berlin. At a joint rally of the Ku Klux Klan and the pro-Nazi German American Bund in 1940, leaders called for a boycott of the song. A week later, an article mockingly titled “G-A-W-D Bless A-M-E-R-I-K-E-R!” appeared in the Bund’s newspaper; the author derided the song as reflecting the “attitude of the refugee horde.”

Through the early 1960s, the chameleon-like lyrics made it a vehicle for a wide range of messages, depending on which direction a given singer wanted the country to be “guided through the night.” In the 1940s, it was sung by anti-Communist protesters as well as by striking laborers. Civil rights activists used the song frequently, including by marchers with Martin Luther King Jr. in Detroit in 1963.

But this multiplicity of meanings became largely unified during the cultural rifts in the mid-1960s, as “God Bless America” increasingly became a symbol for a white, conservative worldview.

In dramatic contrast to the original connection with a message of tolerance, in the late ’60s, the segregationist politician Lester Maddox claimed the song as a personal anthem.

The song’s rightward tilt persisted, but was temporarily suspended in the aftermath of the Sept. 11 terrorist attacks, when it became a sonic emblem of unity and collective mourning.