In those last, fretful minutes in Rome, when every second felt like an age and the final whistle seemed as though it would never come, Liverpool’s fans sang to stave off the nerves.

It was ritual, distraction and prayer: They started with “You’ll Never Walk Alone,” the club’s hymn, switched to “The Fields of Anfield Road” and then, finally, sang, “We Shall Not Be Moved.”

When the game ended, when AS Roma had fallen just short, there was a moment of something close to silence: as if everyone were checking the math, making sure Liverpool really had beaten its host, 7-6 on aggregate, and had reached its first Champions League final in more than a decade.

As the achievement sank in, as Liverpool’s players ran over to the corner of the Stadio Olimpico where the traveling fans had been corralled, another song started, much louder this time, more joyous.

Most of the Roma fans had started for home. Those who lingered might have wondered why, exactly, Liverpool’s fans were celebrating their finest moment in more than a decade by bouncing, twirling their scarves and singing what appeared to be “L’Estate Sta Finendo” (“The Summer Is Ending”), a 1985 hit for the Italian disco duo Righeira.

Liverpool’s fans do not know it as that, of course: In England, it is simply “Allez Allez Allez,” the tune that has provided the jubilant soundtrack to Liverpool’s journey to Kiev this week, to its meeting with Real Madrid in Saturday’s Champions League final.

How the former became the latter, though, how a slice of 1980s Europop became a 21st century Anfield anthem, is a story about the power of YouTube, about the internationalization of the fan experience and about how a melancholy song about the pain of growing up has, three decades on, been given a new life by soccer’s digital culture.

“L’Estate Sta Finendo” did not simply morph into “Allez Allez Allez.” Its journey was circuitous, spreading from L’Aquila, a small city in Abruzzo, in southern Italy, to Turin and Naples and then on, out into the world, to Portugal and Germany, before arriving in Liverpool.

It is not the first chant to have such a winding background: A recent documentary by Copa90 described how “Dale Cavese” — another favorite of a minor Italian team — was adopted from Argentina, popularised and eventually taken up by fans in dozens of countries.

What makes “L’Estate Sta Finendo” different, though, is that its dissemination, and its transformation, occurred almost entirely online.

“It was written when I was 20,” Stefano Righi — better known by his stage name, Johnson Righeira — said of the song he and his partner, Stefano Rota, wrote in the 1980s.

“It is about the end of the summer, the end of the holidays, the start of school, the start of the year. That is a time when loves come to an end, when you know you will not see people ever again. It is the moment when time passes.”

In 1985, it was a hit in Italy, reaching the top of the charts there and picking up airplay in Germany and Switzerland. Righeira did write songs at the time that were adopted by fans — “No Tengo Dinero,” the group’s other major success, was picked up by Roma as a serenade to Toninho Cerezo, a Brazilian midfielder, when the song was first released. But it did not seem that “L’Estate Sta Finendo” would be one of them.

Until, that is, Righi performed in L’Aquila, a city devastated by an earthquake in 2009, “three or four years ago.”

“Afterward,” Righi said, “a few friends of mine sent me a video showing the fans of L’Aquila singing a version of the song.” The first words of this new version were un giorno all’improvviso: one sudden day.

L’Aquila’s team plays in the lower tiers of Italian soccer, but it has a loud and loyal ultra group, known (for the team’s colors) as the Red-Blue Eagles. They are widely credited with transforming “L’Estate Sta Finendo” from a forgotten disco hit into a stadium chant in 2014, but confirming that as truth was difficult: A leader of the group told The New York Times the ultra code prevented him from speaking to the news media on or off the record.

From L’Aquila, though, the song spread quickly through Italy: Genoa had a version, and so did Juventus, Righi’s favorite Italian team. It was Napoli, though, that took to it most keenly. “It is almost a hymn there,” Righi said. Each new group changed the lyrics, though each one started with the same three words: un giorno all’improvviso. Just before the chorus, Napoli’s fans chanted that they would “defend the city.”

From there, the song took flight. Atlético Madrid adopted it — the club’s fans sang it during the Europa League final last week — and so did Rangers in Scotland. Righi tracks it all as much as he can; friends still send him video they find of new editions. “I’ve heard it sung at basketball games and hockey games, too,” Righi said.

The Super Dragons, FC Porto’s ultra group, noticed it, too. The group’s leader, Fernando Madureira, confirmed by text message that his cohort had seen a YouTube clip of Napoli’s ultras in action and decided to borrow the tune. By February 2016, when the club visited Borussia Dortmund in the Europa League, it had become one of its standards. During a visit to Germany, a group of Super Dragons was filmed singing it at a subway station.

As far as Madureira is concerned, Liverpool lifted it directly from Porto: The teams played in the Champions League’s round of 16 this season, and Madureira said he believed Liverpool’s fans took the song up spontaneously in the stadium. The reality, though, is a little more convoluted.

A few weeks after Porto played Dortmund in 2016, Phil Howard, a Liverpool fan from Wavertree, watched the video of the Super Dragons in the subway station. He had been in Dortmund for Liverpool’s game there, and was searching for clips on YouTube, “trying to see if I was in any of the videos.”

Disappearing down a YouTube rabbit hole, he came upon the Porto video. “I wanted to do a version of it straightaway,” he said. “As stupid as it sounds, I didn’t want Manchester United or Chelsea to get hold of it.”

Howard texted a friend, Liam Malone, to alert him to the song. “I told him this could be the next ‘Ring of Fire,’ ” he said, referring to the Johnny Cash song that provided the soundtrack to Liverpool’s 2005 Champions League win.

It took the two of them some time to come up with acceptable lyrics: It was not for 18 months, till December 2017, that Malone had a flash of inspiration. For the next few weeks, he and Howard tried to spread the word and popularise their creation: They were both at the game in Porto — three months later — where groups of Liverpool fans started singing it on the concourses and in the stands.

Jamie Webster, an electrician and acoustic guitarist, was there, too. “I’d heard murmurs of it at Anfield before,” he said. “But in Porto there was a group of lads singing it. People did not know the words, but they were trying to follow them.” He saw the potential in the chant, too. He found the song online, deciphered the lyrics, and started setting it to music. “I wanted to get it out there,” he said.

Webster had the perfect stage. He performs regular sets at two venues that have become cornerstones of Liverpool’s match-day scene: at the Halfway House pub near Anfield and at the BOSS Night events, run by a local music magazine. When he gave his version its debut a few days after the Porto game, the reception was rapturous. “It took four or five times, and the whole pub was up,” he said. “I’m talking women in their 50s on tables, that sort of thing.”

Film from that night was uploaded to YouTube, shared on Facebook and Twitter, and viewed hundreds of thousands of times. “It just spiraled and spiraled,” Webster said. Webster is now asked for his autograph by those who have seen clips of his shows. Earlier this season, a group of fans from France came to Anfield determined to meet him.

The song, though, is bigger still. By the time Liverpool beat Manchester City in the Champions League quarterfinals in April, all of Anfield was singing it.

That moment — in Webster’s mind — sealed the song’s place in the Liverpool canon. “These songs breed through success,” he said. “If we had lost against City, maybe the whole thing would have died off.”

Liverpool did not lose, though. The song rang out loud and clear in both legs of the semifinal against Roma; you will hear it, again and again, during Saturday’s final in Kiev, the biggest stage club soccer has to offer.

That night, Righi will be expecting a slew of new messages from friends, sending him clips of his song booming out in Ukraine, sung by fans of an English soccer team, who picked it up from a YouTube video of Portuguese ultras singing in Germany, who took it from Naples, who borrowed it from L’Aquila.

“Every version gives the song a new life,” he said. “It is very emotional for me. It makes me very happy. I always think that songs are like children: When they become big, they leave home, and they go their own way.”

This one has gone farther than most. It has conquered all of Europe. It’s never going to stop.

NYT Services