The U.S. women’s national soccer team has been incomparable for decades and invincible for more than two years. Excellence is the expectation in each match, and even if the outcome is not an entertaining victory, it’s often affirmation of the Americans’ iron grip on the sport.

But with the Olympics approaching and vulnerabilities revealing themselves, a fifth gold medal is far from a foregone conclusion.

On Saturday, a 1-1 draw with Sweden at a friendly in the Stockholm suburbs exposed cracks in the U.S. machine. Trailing for the first time in 18 months, the top-ranked team in the world received a favorable call in the waning moments, which led to Megan Rapinoe’s penalty kick that extended its unbeaten streak to 38.

“If we play the way we played today, it’s not good enough,” said Vlatko Andonovski, whose 16-game winning streak to begin his U.S. women’s coaching tenure ended. “I know that. Nobody has to tell me that, but it’s just a good learning opportunity for us to get better.”

After many breezy victories since they claimed the 2019 World Cup title, the Americans said they welcomed adversity in the lead-up to another major tournament.

“Even throughout the whole game I was thinking, ‘This is exactly what we need,’ ” Rapinoe said. “We didn’t play well. We were very sloppy. Tactically we needed to be a lot better. But those are the games you have to dig in and all kind of look at each other.”

The Americans have not lost since a January 2019 defeat to France in Le Havre — the venue for Tuesday’s test against the third-ranked French. They appeared on their way to losing to No. 5 Sweden, though, after they conceded Lina Hurtig’s goal in the 38th minute.

The equalizer came in the 87th after Kelley O’Hara was taken down by Sofia Jakobsson at the edge of the box. Though the contact appeared to take place outside the area, referee Lina Lehtovaara awarded the penalty.

Without video replay available in friendlies, Sweden had no recourse, and Rapinoe slotted in her 58th career goal.

To that point, the United States had few clear chances against Sweden, which ousted the Americans in the 2016 Olympic quarterfinals. And for the first time in Andonovski’s tenure, his team faced a deficit.

“It’s a position we haven’t been in in a while,” defender Tierna Davidson said. “So it was a good challenge for us.”

Andonovski was displeased with several elements.

“Our touch was off. Our pass was off,” he said. “When we were able to break them down, it was the same thing. We were not good enough.”

In a compact Olympic schedule, such shortcomings could prove costly, particularly in the knockout stage against medal contenders. Andonovski was also disappointed about conceding a goal off a set piece — “something we pride ourselves on,” he said.

The Americans were forced to problem-solve to try to unlock the Swedish defense in the final third of the field, and they were not very successful.

“As we approach the summer, we’ll get much sharper on solving problems quickly and not having to wait until halftime, not having to wait until we have conversations about things,” Davidson said.

The best first-half threat came on Rose Lavelle’s rasping drive that goalkeeper Jennifer Falk parried aside.

Sweden went ahead on a corner kick as Kosovare Asllani set up Hurtig’s near-post header. At 5-foot-11, Hurtig was the tallest player on the field, and on a set piece, she should have been closely marked. But assignments were missed, and the forward was given an uncontested run-up. Goalkeeper Alyssa Naeher was too late coming off her line, and Hurtig drove a six-yard header off the far post, ending the Americans’ shutout streak at six games.

The previous time the Americans had trailed was in Jill Ellis’s farewell match as coach in October 2019 against South Korea, which also ended in a 1-1 draw.

Naeher prevented a deeper deficit before halftime, making a terrific save on Fridolina Rolfo after the Swedish forward had collected Lindsey Horan’s errant pass and beaten Davidson.

Andonovski turned to the bench early in the second half, inserting three usual starters who also happen to be three of the best attackers in the world: Rapinoe, Alex Morgan and Sam Mewis.

The Americans struggled to find rhythm and fluidity as Sweden calmly defused potential threats and pressed for a clinching goal. The equalizer eventually came but under dubious circumstances.

“The more competition, the more we can get punched in the mouth,” Rapinoe said of Olympic preparations. “Tokyo is going to be one big punch in the mouth. ... [The Sweden game] was a punch, but we took it.”

Note: Forward Carli Lloyd, 38, made her 300th national team appearance, joining former stars Kristine Lilly (354) and Christie Pearce Rampone (311) in that club.

More from The Post: