For the first time in its distinguished history, the U.S. women’s soccer team has failed to advance to the semifinals of a major tournament.

The four-time Olympic gold medalists were upset by Sweden on penalty kicks, 4-3, following a 1-1 draw Friday at Mane Garrincha Stadium in Brasilia.

The top-ranked Americans had gotten past the quarterfinals in seven World Cups and earned no worse than silver in five previous Olympics. But on this day, Sweden, guided by former U.S. coach Pia Sundhage, prevailed in the tiebreaker to claim a semifinal slot against Brazil or Australia on Tuesday in Rio de Janeiro.

Live updates: Latest news and results from Rio

The United States, unbeaten in 18 prior matches this year, was seeking to win a fourth straight gold medal and become the first team to win World Cup and Olympic titles in consecutive years.

“It’s hard to go back to back — that’s why no one has done it,” captain Carli Lloyd said. “It’s unfortunate. We had the talent. We were playing well. That’s the way soccer goes sometimes.”

Against the run of play, sixth-ranked Sweden went ahead in the 61st minute when substitute Stina Blackstenius scored on a clinical counterattack. The Americans answered in the 77th when Alex Morgan took advantage of a deflection and scored from 10 yards.

In the first tiebreaker in Olympic women’s history, each goalkeeper made a save in the first three rounds. After both teams converted in the fourth stage, Christen Press drove her shot over the crossbar and Lisa Dahlkvist beat Hope Solo to clinch victory.

The match transpired exactly as expected: the United States hoarding possession while Sweden absorbed pressure and, in soccer parlance, parked the bus to compress space and thwart opportunities.

After the game, Solo remarked on the contrasting styles in blunt terms.

“I thought that we played a courageous game,” she told reporters. “I thought we had many opportunities on goal. I think we showed a lot of heart. … But I also think we played a bunch of cowards. The best team did not win today. I strongly believe that.”

Asked to explain her criticism of the Swedes, Solo said: “They didn’t want to pass the ball. They didn’t want to play great soccer. It was a combative game, a physical game. Exactly what they wanted and exactly what their game plan was. … I don’t think they’re going to make it far in the tournament. I think it was very cowardly. But they won. They’re moving on, and we’re going home.”

Told of Solo’s comments in her postgame news conference, Sundhage retorted: “It is okay to be a coward if you win.”

U.S. Coach Jill Ellis told reporters, “I’m sad for the players, disappointed for all the hard work we did” but said of Sweden’s play: “I’m not going to criticize the tactics they chose. It is a choice to play defensively and it is okay.”

The Americans took hold of the match at the very start, putting Sweden under severe duress. In the third minute, Morgan’s header was cleared by a defender at the back post and Morgan Brian’s bid was pushed away by goalkeeper Hedvig Lindahl.

Sweden defended in numbers, clogged channels and won aerial challenges. The United States moved the ball well, emphasizing the right flank with Tobin Heath, but failed to link the final pass and failed to serve quality crosses and set pieces.

The Swedish weapons were counterattacks and corner kicks. Becky Sauerbrunn and Julie Johnston extinguished potential threats in the run of play, but the U.S. defense looked uneasy at times on set pieces. Solo, who conceded two goals on Colombian free kicks in the group finale, did not have to make any difficult saves in the first half but had to remain vigilant against a limited but smart and composed opponent.

The Americans had a golden chance early in the second half, but after an exchange with Heath on a free kick just beyond the penalty area, Lloyd missed wide on a clear attempt. A minute later, the United States drew another free kick from striking range. Lloyd went for goal but cleared the crossbar from 28 yards.

Sweden’s tactics tested the Americans’ patience and slowed the pace to a crawl. The onus was on the United States to crack the unbending resistance and open up the match. A goal, by any means, would accomplish that, but as the second half proceeded, Sweden kept its nerve.

As Jill Ellis prepared to make changes, the Swedes executed a textbook counterattack to claim the lead. After they broke out of their end, Dahlkvist threaded a long through ball into a central channel. Blackstenius, who had entered in the 18th minute for the injured Fridolina Rolfo, beat Sauerbrunn to the ball and fired a low shot past Solo and into the far corner.

Gorgeous. Sweden up over #USWNT, 1-0.
— Our Game Magazine (@OurGameMagazine) August 12, 2016

Ellis turned to her bench, replacing defensive-minded players (Allie Long and Kelley O’Hara) with attackers (Crystal Dunn and Megan Rapinoe). The breakthrough finally arrived in the 77th minute. At the top of the box, Dunn flicked a header that caromed off Jessica Samuelsson and fell to Morgan for a left-footed one-timer into the lower-left corner, her fifth career Olympic goal.

Alex Morgan equalizes for the #USWNT. — Our Game Magazine (@OurGameMagazine) August 12, 2016

Lloyd threatened to break the tie in the 84th minute. After Dunn laid the ball off to her, Lloyd cut back and shot toward the open far corner. A defender, however, deflected it wide, prompting Lloyd to grab her head in disbelief. A moment later, Lindahl made a soaring save on Heath’s threat.

Extra time beckoned.

In the 99th minute, Press replaced Rapinoe, who on Tuesday had returned from an eight-month injury layoff and was only capable of playing 30 minutes or so. In the 101st minute, Lindahl closed down Morgan’s angle and thwarted the attempt.

After Mallory Pugh left late in the extra period with an injury, allowing Lindsey Horan’s entry, both teams had goals disallowed.

Lloyd headed in Dunn’s cross but was incorrectly ruled offside. (She also appeared to pull down defender Magdalena Eriksson.) A minute later, Sweden’s Lotta Schelin was wrongly ruled offside after collecting a deflected ball alone in the box and shooting past Solo.

Penalty kicks would have to settle the outcome.

“It could have gone either way,” Lloyd said. “Overall, we played well. It’s unfortunate to lose, but you best believe, in 2019 [World Cup in France] and 2020 [Olympics in Tokyo], we’re going to be back for the golds.”

USA lineup: Solo; O’Hara (Rapinoe 72nd, Press 99th), Johnston, Sauerbrunn, Klingenberg; Brian, Long (Dunn 65th), Lloyd; Heath, Morgan, Pugh (Horan 114th). Olympic rules allow for a fourth substitute in extra time.

Rick Maese contributed from Rio de Janeiro.