REIMS, France — Spain tested the United States like no other team at the Women’s World Cup.

The Spaniards played an aggressive and physical game that made the U.S. look disorganized at times before the Americans pulled out a 2-1 victory Monday.

It could have been just what the Americans needed with France waiting. Megan Rapinoe converted a pair of penalty kicks to set up the United States’ much-anticipated quarterfinal rendezvous with the hosts.

The tense match was knotted at 1 until Rapinoe’s second penalty put the defending champions ahead in the 75th minute.

“I think we showed just a lot of grit and experience, to be honest, in this game,” Rapinoe said. “Obviously as we get into these knockout rounds it’s more stressful, there’s more pressure, the games are more intense. Every team lifts its level.”

Rapinoe’s first came in the seventh minute to the cheers of the U.S. supporters melting in temperatures that reached nearly 90 degrees at the Stade Auguste-Delaune. They were quieted a short time later when Jennifer Hermoso tied it up for Spain with the first goal the Americans had allowed in France.

Video review was used to confirm a foul on Rose Lavelle that gave the pink-haired captain the game-winner, spoiling Spain’s spirited effort in its first knockout-round appearance at a World Cup.

The three-time World Cup winners now head to Paris to face France on Friday night. The French defeated Brazil 2-1 in extra time Sunday night, with Amandine Henry scoring the game-winner in the 107th minute.

“I think this is the game that everyone had circled,” Rapinoe said, referring to France. “I think it’s going to be a great match. I hope it’s wild and crazy, I hope the fans are crazy and there’s tons of media around it and it’s just a big spectacle. I think this is incredible for the women’s game.”

The game at the home of Paris Saint-Germain has been anticipated since the tournament draw in December. France is vying to become the first nation to simultaneously hold both the men’s and women’s World Cup titles. The French men won in Russia last year.

The United States skated through its group with a stage record 18 goals. The team also didn’t concede a goal in the group stage for the first time at a World Cup.

Until Monday, the Americans had not allowed a goal in eight straight competitive matches dating to the 2016 Olympics, outscoring opponents 44-0. It was the first goal they had allowed this year since a 5-3 win over Australia in an April friendly.

“This tournament isn’t supposed to be easy, and Spain was a great team,” midfielder Samantha Mewis said. “I think these are the kinds of things that let us know that we’re strong and that we can grind through something. So I think we’re gonna take a lot from this and it gives us a lot of faith in ourselves.”

Rapinoe collected a yellow card in the 37th minute against Spain. The cards could become an issue going forward. Players who accumulate two through the quarterfinals must sit out the next game.

Ellis, who coached her 124th match to match April Heinrichs for the most in team history, said she felt Spain’s challenge will benefit the Americans come Friday.

“I think what this game gave us and the takeaways from it — massive,” Ellis said afterward.