In the shadow of the Brandenburg Gate, in a city scarred, then divided and reborn, the final moment of the 2014 World Cup brought a sound once rare in this capital: the collective scream of German pride.

Fireworks erupted across the city, car horns blared and a stoic nation dropped its guard in bear hugs, beer-mug toasts and tears of joy. In Rio de Janeiro, an ecstatic German Chancellor Angela Merkel — a soccer fan extraordinaire — staged an impromptu receiving line to kiss the 11-man team. On the “fan mile” in central Berlin, where tens of thousands braved preternatural summer chill and early rain, Alexander Nolte, 24, captured the sentiments of a nation that views the victory as a harbinger of changing times.

“I feel amazing, unbelievable, this is pure euphoria. I hope that I won’t wake up tomorrow and find out that it’s a dream,” said Nolte, an electronics engineering student. “This victory will be pure prestige for Germany, and it could also affect other areas beyond sports, like politics and the economy.”

Sunday’s fourth World Cup title for Germany — its first as a united team following reunification — will be remembered here as a touchstone moment in a nation at a crossroads in its post-World War II history. In the past five years, Germany has emerged as Europe’s reluctant leader, an economic superpower and a model for harnessing the promise of globalization.

The right to national pride was thought lost after the grim tableau of the war. But Sunday’s joyous sea of black, red and yellow — the colors of the German flag clutched in hands from the Baltic Sea to the Alps — seemed to mark a new leap forward here, moving Germany down a path toward a 21st-century relationship with patriotism and identity.

Locked in disagreement with the United States over spying and cautiously engaging a newly belligerent Russia over the crisis in Ukraine, Germany is weighing its role in the world. For millions of Germans, it made the World Cup victory not only pure pleasure, but an exercise in soul searching.

“We’re back, but as what?” Germany’s Der Spiegel magazine asked on the cover of Sunday’s editions.

As in all countries, the World Cup has a way of stirring national pride. After being banned from competition after the war, Germany’s return in 1954 brought a stunning victory in the finals as West Germany beat Hungary, spurring fans in attendance to sing Germany’s national anthem.

Yet the shadow of the past continued to dim every corner of life here. Even into the 1990s, flagpoles at schools were bare of the national flag and children weren’t taught the national anthem.

Only in 2006, when Germany hosted the World Cup, were black, red and yellow tentatively draped from windows and attached to car antennas. In an illustration of the “new Germany” that arose after years of immigration and economic growth, the most fervent flag-waving came from this nation’s large Turkish immigrant community — regarded as the fan bloc that opened the gates to more public displays of patriotism.

Germany’s soccer prowess in the past decade has paralleled its economic reemergence on the world stage. In the late 1990s, well-funded soccer academies were geared toward producing champions. And that they have and not all with names such as Muller. Turkish-German players Mesut Ozil and Ilkay Gundogan joined the German team after 2008, along with Tunisian-German Sami Khedira, recasting the identity of German soccer.

“My family is Turkish, but this is my country,” said Murat Yelcin, a 29-year-old cab driver in Berlin who was sporting a German flag on his dashboard Sunday. “This is going to be a win for all Germans.”

In Germany, the World Cup is redefining patriotism. During the game, for instance, a young German boy walking with his mother in the Berlin neighborhood of Kreuzberg pointed to a waving German flag and said, “Oh, Mama, fussballstreifen,” or football stripes.

“We have proved once more that we are a strong country,” said Vivian Schmitt, 36, a German pornographic actress wearing a Germany jersey and celebrating Sunday night near the Brandenburg Gate. “We are simply number one. We know our history, but still we have the right to be proud today no matter what happened years ago.”

But this is Germany, and even as a new generation of Germans feels less chained to history, the weight of the past proved too much for some — particularly older Germans and those who hold fast to the nation’s pacifist ideals. Critics, disgusted by the show of nationalism brought out by the World Cup, resorted to removing and disposing of the omnipresent German flags on cars and lining streets. Others lobbied for a ban on flags. Still others called for their removal from public spaces.

Bratwurst and a big-screen TV was how Sylvia Griffin, 66, watched the match with her husband in the Berlin suburb of Panketal. But the die-hard soccer fans remained silent during the German national anthem, unable even now to sing the words.

“We thought national pride was something to avoid at all costs,” Griffin said. “Patriotism — the way the Americans live it — always smacked of nationalism to my generation. And nationalism had driven this country into two wars and worse.”

And even if some Germans feel the time has come when they can freely celebrate a national triumph with patriotic fervor, the world still insists on the past. On the day of Germany’s historic 7-1 rout of Brazil last week in the semifinals, for instance, Twitter experienced a major worldwide surge in references to “Nazis,” “Blitzkrieg” and “Hitler.”

The old jibes came even as the Germans seemed to go out of their way last week to avoid gloating after beating Brazil. Many Germans were caught wincing as their team racked up the points.

“The rejoicing after the game was rather restrained,” said Gunter Gebauer, a professor at Free University Berlin who studies the philosophy of sports. “Of course there was huge excitement. . . . But I think Germans were also a little bit shocked about the success. Because in Germany, like in many other countries in the world, there’s a big admiration for Brazilian football. . . . It would have been better if Germany had won 3-1.”

Stephanie Kirchner contributed to this report.