LAS VEGAS — When time expired and the helmets and sticks were tossed into the air, the Washington Capitals poured onto the ice, and a celebration decades in the making ensued. The players hugged each other in joy and shook each other in disbelief.

Team captain Alex Ovechkin was on the edge of the scrum, bouncing and screaming, trying to make sure his voice could be heard from Las Vegas to Washington to Moscow.

As the trophy made its way onto the ice, some 2,400 miles away, a sea of red — jubilant Capitals fans who filled the streets in downtown Washington — erupted, too. The win was a season in the making for many on the ice and a lifetime in the making for so many fans back home.

The Stanley Cup, the most storied trophy in sports, is coming to Washington, courtesy of a pair of Russian scoring machines, a journeyman-turned-hero, an unflappable goaltender and a supporting cast that confronted a season’s worth of challenges with careers’ worth of determination.

The Capitals topped the final foe, the Vegas Golden Knights, 4-3, in exciting fashion Thursday night in Game 5 of the Stanley Cup finals. The comeback victory gave the Capitals a four-games-to-one series victory and secured the first National Hockey League championship in the franchise’s 44-year history — and the city’s first title in any of the four major American sports in more than a quarter-century.

“I can’t explain what I feel,” Ovechkin said when it was over. “It’s unbelievable.”

The finale was tense from start to finish: the hard hits in the opening period, the explosion of scoring in the second and the winning goal off the stick of center Lars Eller in the third. It amounted to three periods of racing hearts and bated breath, electrifying a region of sports fans well-versed in disappointment but largely unaccustomed to the sensation that suddenly swept over them late Thursday night.

How fans celebrated the Capitals? Stanley Cup victory

Fans outside Capital One Arena in Washington erupt after watching the Capitals win their first Stanley Cup, defeating the Golden Nights, 4-3, in Las Vegas. (Michael Robinson Chavez)

After Vegas built a 3-2 lead in the second period, Washington had to claw its way back and did so thanks to one of the unlikeliest stars of these playoffs. Forward Devante Smith-Pelly scored a total of seven goals in the regular season. His tying goal with 10:06 remaining in the third period of Thursday’s game was his seventh of the postseason, his third of the finals.

Barely two minutes later, the Capitals struck again. Vegas goaltender Marc-Andre Fleury blocked Brett Connolly’s shot but didn’t secure the puck. Eller was positioned perfectly on the edge of the crease, scooping the puck from behind Fleury and into the net.

The pair of quick scores lit a fire under the raucous contingent of red-clad fans who made the trek west for the game — not to mention the thousands who had turned much of the Washington region into a giant outdoor party. Many of them had dreamed of this moment for years, yet were still wholly unprepared for it.

No D.C. sports fan born in the past two decades had ever experienced the feeling. From Ovechkin’s gaptoothed grin to the thousands of delirious fans who set up camp downtown, for a night turning Chinatown into Titletown, the moment encapsulated years of disappointment, hurt and anticipation — all of it corked, shaken and unleashed.

Fans hugged strangers. Strangers high-fived police officers. Cab drivers stopped their cars to take pictures. Everyone seemed to pause in the middle of the street just to scream. The scene was mayhem, the soundtrack of horns everywhere, honking in rhythm.

“D.C. is alive,” said Zack Vinson, 29, of Ashburn.

“Unlike anything I’ve ever seen before,” said Mark Creamer, 22, of Gaithersburg.

Near Capital One Arena in Northwest D.C., Seventh Street was packed, overflowing. People sprinted down H Street, screaming, cursing. Cars everywhere honked the “Let’s Go Caps” rhythm. Fans chanted “C-A-P-S” and screamed. Traffic nearby didn’t move, and the honks provided a chorus to a celebration that grew as more and more people ran into the mayhem. “Congratulations,” they screamed to strangers, voices cracking.

“My goal was always to build a team as good as the fan base,” Capitals owner Ted Leonsis said. “I think we have the best fans in the world and now we have the best hockey team in the world.”

Washington’s sports teams had played a combined 71 seasons since the last D.C. team played for a title — since the Capitals reached the Stanley Cup finals in 1998. No Washington team had won a championship since the Redskins in 1992. All the local teams have done since then was tantalize and tease. Thirty-nine times Washington teams have reached the playoffs since that Redskins title, and every time they bowed out early — until Thursday.

Perhaps no franchise, though, has been as maddening and exhilarating as the Capitals, stoking hopes every spring and promptly extinguishing them. No team in any of the four major American sports leagues, in fact, had as many postseason appearances before finally winning a title. The Capitals had reached the playoffs 28 times, dating from 1983, including eight of the past nine years. And year after year, they found new ways to disappoint.

This was, in fact, among the most unlikely Capitals teams to make a deep run. Some analysts speculated after last season’s early playoff exit that it was time for the Capitals to move on from Ovechkin. The team parted ways with a handful of key players last offseason and opted against an extension for Coach Barry Trotz, whose contract expires July 1.

The Capitals had a losing record one month into the season and their flashes of brilliance were often matched by inexplicable lapses. The Capitals didn’t assume first place in the Metropolitan Division to stay until March 10 and finished the regular season tied for the conference’s third-best record.

“Throughout the whole year, not a lot was expected out of us,” forward T.J. Oshie said. “Maybe on paper we weren’t as elite as teams past. But man, did we ever come together.”

Still, they looked little like the team that would start to coalesce several weeks later, losing their first two games of the playoffs against the Columbus Blue Jackets, sending fans on a familiar ride of disappointment. But Trotz switched goaltenders, replacing Philipp Grubauer with Braden Holtby, and the Capitals started getting the kinds of bounces that once eluded them. They clawed their way back to oust the Blue Jackets, and their reward was a second-round matchup against the Pittsburgh Penguins, a nemesis that had bested the Capitals in their previous seven postseason meetings, including each of the past two years.

But Ovechkin, Evgeny Kuznetsov and the Capitals kept scoring, Holtby kept shining in net, and Washington bound over the second-round hurdle that had been insurmountable. In the conference finals, they would need all seven games to top Tampa Bay and punch a ticket to the Stanley Cup finals, where the most unlikeliest of opponents waited. Vegas was an expansion franchise that surprised throughout the regular season and playoffs, including in Thursday’s whirlwind second period in which the Golden Knights scored three times. But the Capitals showed resilience, seasoned by years of hope and disappointment and star players who will be treated like heroes in D.C. for a long time.

“To me, they changed all the narratives,” Trotz said, “checked off every box. . . . It was probably fitting we were down in this game and had to come back.”

After the game was finished and the Capitals had completed the comeback, the Stanley Cup was carried onto the ice by a pair of league officials wearing white gloves. NHL Commissioner Gary Bettman called up Ovechkin first.

Overcome with emotions, the 32-year-old captain lifted the trophy over his head, planted a kiss on it and took it for spin down the ice, showing off the sport’s biggest prize for the rest of the world. He passed it off to Nicklas Backstrom, who gave it to Brooks Orpik. And then Oshie and Jay Beagle and Holtby. It was passed from player to player, champion to champion.

Every one of them had been reminded over and over how Washington teams disappoint, how the Capitals, especially, break hearts. They shrugged off history. They made history. They’re bringing the Stanley Cup to Washington, a city that has waited more than a quarter-century to celebrate a champion.

Dan Steinberg contributed from Washington.