REIMS, France (AP) -- Spain tested the United States like no other team at the Women's World Cup.
The U.S. looked disorganized at times facing Spain's aggressive and physical style before pulling out a 2-1 victory Monday night.
It could have been just what the Americans needed: France is 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, when you have two heavy hitters meeting in the final knockout round."
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 the United States 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."
La Roja had not scored in its previous two games but still finished second in its group to Germany to get the matchup with the Americans.
The U.S. and Spain last met in a friendly in Alicante in January, part of a European exhibition trip for the United States. Christen Press scored the lone goal in a 1-0 victory. That match was a confidence-booster for No. 13 Spain because it was able to hang with the world's top-ranked team. Spain's profile on the international stage has grown under coach Jorge Vilda, who took over following the team's World Cup debut in 2015. Spain won the 2017 Algarve Cup and last year won the Cyprus Cup.
Spain pushed the U.S. hard Monday.
"I actually think we deserved it more, but you know sometimes football is like that. I'm so proud of the team," Spain midfielder Vicky Losada said. "I'm so proud of the effort of the team and I think now we have to think about it, and think about the future, which I think is going to be so good."
Rapinoe's first penalty kick was the result of Maria Leon's tackle on Tobin Heath after a pass from Abby Dahlkemper.
Less than three minutes later, goalkeeper Alyssa Naeher's pass to Becky Sauerbrunn was stripped by Lucia Garcia and the ball wound up at the feet of Hermoso, who sent her shot from the penalty arc into the top right corner. It was Hermoso's third goal of the tournament to lead Spain.
Alex Morgan was set to take the penalty after Lavelle was tripped up by Virginia Torrecilla, but after the review Rapinoe stepped forward and slotted the ball just under the outstretched arm of Spain goalkeeper Sandra Panos.
Sauerbrunn was grateful.
"She's never going to have to buy another drink for the rest of the time. I will supply her with whatever she needs," she said.
Morgan, who leads the field in France with five goals, took a beating throughout the game and was seldom a factor. She stayed down for a long while in the second half after a hard tackle by Irene Paredes.
Coach Jill Ellis did not start midfielder Lindsey Horan, replacing her with Mewis. Horan, who came in as a sub in the 89th minute, had a yellow card in the team's second match.
Rapinoe collected a yellow card in the 37th minute against Spain. The cards could become an issue for the United States 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.