LONDON — England came so close. But in the end, it didn’t bring it home.

The country’s men’s national soccer team lost to Italy on Sunday in a penalty shootout in the final of the European Championship at Wembley Stadium, but its fans hailed the team as doing its nation proud. Manager Gareth Southgate’s young squad made it to the final of a major international tournament for the first time in 55 years.

It wasn’t the fairy-tale finish it wanted or was so close to achieving, but its performance, on and off the pitch, unequivocally lifted the hearts of this soccer-mad nation after a brutal year. The tournament also prompted discussions about a new vision of Englishness in the post-Brexit era, with this team symbolizing diversity and inclusivity. At the same time, it highlighted the rampant racism aimed at players that continues to thrive online — and that emerged again in the hours after England’s loss.

The Three Lions fell, 3-2, in a nerve-shredding shootout after playing Italy to a 1-1 draw. Three of their youngest players — Marcus Rashford, 23; Jadon Sancho, 21; and Bukayo Saka, 19 — failed to convert.

Boris Johnson, the British prime minister whose passion for soccer was previously unknown, was among many politicians who in recent days loudly cheered on the home team. He tweeted the result was “heartbreaking” but that Southgate and his team “have done the nation proud and deserve great credit,” and he decried those posting racist insults, saying “those responsible for this appalling abuse should be ashamed of themselves.”

Labour Party lawmaker David Lammy tweeted: “Heartbroken we lost, but still so proud of this team. They are the best of England in all its talent, teamwork and inclusivity. A couple more years of hurt will never stop us dreaming.”

Fans celebrated across Rome after Italy beat England in a penalty shootout to win the Euro 2020 championship on July 11. (Luis Velarde, Drea Cornejo/The Washington Post)

After decades of failure and underachievement since England’s last major championship at the 1966 World Cup, some dared to dream that this could really be the year when England triumphed. But 2021 was not the year “football is coming home” — a refrain from a song that has become something of an alternative national anthem in recent weeks.

England had a stellar start when it scored in the second minute. Luke Shaw’s finish off a picture-perfect cross was the fastest goal scored in a European Championship final.

Seven-year-old Prince George, in blue blazer and tie, whooped it up. His expression, which was something akin to gleeful astonishment, seemed to sum up the mood of many in England at the moment.

David Beckham, a former England captain, also was in attendance and turned to actor Tom Cruise and gave him a fist bump.

But the euphoria didn’t last. Italy tied the score at 1 with a goal from Leonardo Bonucci in the 67th minute.

And so four weeks of tournament play came down to penalty kicks. Announcers described the last moments as unbearable and advised viewers to hide behind their sofas if needed. The English fans at Wembley covered their eyes, held their heads.

Few things unite England like soccer — more than 30 million people watched the final game, the biggest television viewing audience since the funeral of Princess Diana in 1997.

To say the country was hyped about the final and the possibility that its 55-year curse could be broken was an understatement.

In the lead-up to Sunday’s match, Queen Elizabeth II penned a short note to Southgate, sending her good wishes and paying tribute to his team’s “spirit, commitment and pride.” Houses, pubs and fans around the country draped themselves in the St. George’s Cross flag, the flag of England that really only comes out en masse during big soccer tournaments.

Nigella Lawson, a celebrity chef, tweeted a recipe of her “Anglo-Italian trifle” with the caption, “opposed in football; united in food.” Other English fans showed less sportsmanlike qualities, tweeting messages about how they were putting ketchup on their pasta.

Thousands of fans started early Sunday. People started queuing outside pubs early in the day for the 8 p.m. kickoff and were allowed to stay until 11:15 p.m. The government extended opening hours Sunday night in case the game went to extra time, which it did. Initially, many of the street scenes had a festive, carnival feel, with full-voiced singing, cheering and honking. But as the beer flowed and the hours passed, some of the scenes turned ugly.

Ticketless fans tried to rush through the gates at Wembley as security rushed to stop them. Wembley said a “small group” of people got into the stadium.

In Leicester Square, fans threw bottles and projectiles. King’s Cross station was evacuated after a fire alarm was set off by England fans setting off flares.

The London Metropolitan Police also said they had made 49 arrests while policing the final.

Later, on social media, some supporters directed racist comments toward the players who failed to convert their penalty kicks, drawing condemnation from England’s Football Association. Prince William, the president of the English Football Association, said he was “sickened” by the remarks. The Metropolitan Police said they were launching a probe.

London Mayor Sadiq Khan called on social media companies to do more to “remove and prevent this hate.”

He tweeted his support for the trio of players on the receiving end of the abuse, calling them, simply, the “Three Lions.”