In the United States' toughest challenge at the Women's World Cup so far, two Megan Rapinoe penalties, one in each half, secured progress to the last eight.
It was widely believed that the Americans would not be sternly tested until the quarterfinals, at an anticipated clash in Paris on Friday, but Spain was far from the obliging opponent many had expected.
The US' defense wobbled, an attack regarded as the most potent in the competition was stifled, and for much of the match, Spain was the US' equal. So successful was Spain in frustrating the Americans that Jill Ellis' side had to rely on a late -- and much-questioned -- penalty to see off a team competing in the knockout stages of the World Cup for the first time.
Ellis described the performance as a "lot of grit, a lot of resolve."
"You can have all the tactics in the world, but that essence of self-belief, that's critical, and these players have that," she said after the match.
"Spain came out and wanted to physically mix it up. At times, our movement could've been a little better to deal with that, but you want to make sure that you have a person in the middle who can take care of the game and control those situations as well.
"It's part of this level, in terms of the intensity and the physicality of the matches, and I think it will actually get us ready for the next match."
When Spain conceded a fifth-minute penalty -- Maria Leon bringing down Tobin Heath in the box -- it seemed as if the United States would go on to accrue another healthy scoreline, just as it did in the group stages.
Ellis' team had qualified for the last 16 having scored 18 goals in three games and not conceded, becoming the first team in World Cup history to qualify for the knockout stages with a +18 goal difference.
But before this tournament, questions were raised about the US' defense, and for the first time, it was put through its paces and breached. France, a team with forwards who could cause the Americans a number of problems, will undoubtedly have taken note.
In trying to play out from defense, Becky Sauerbrunn lost possession on the edge of her box, and Spain pounced with a delightful finish from Jennifer Hermoso.
The defending champion created more chances -- Rapinoe twice missed opportunities to regain the lead -- but so too did Spain, catching out the Americans' high defensive line on a couple of occasions.
Spain's ploy of slowing the pace of the game by keeping possession worked until Virginia Torrecilla challenged Rose Lavelle inside the box and the referee, without hesitation, pointed at the spot.
Though it appeared to be the slightest of contacts, a VAR check rubber-stamped the decision, and Rapinoe coolly slotted home for her third goal of the competition.
In theory, it should have been a far simpler assignment for the US, the most successful country in the competition's history. Spain may be a passionate football nation -- the men won the World Cup in 2010 -- but for the most part, the women's game has been an afterthought.
After the 2015 Women's World Cup, the national team players called for the sacking of then-manager Ignacio Quereda, and after 27 years at the helm, Quereda stepped down from his post that summer.
Under his successor, Jorge Vilda -- at 37 the youngest coach at the tournament -- much has changed, and the tenacity and talent of the players in only the country's second Women's World Cup was testimony to the improvements made in recent years.
After defeat by two-time champion Germany in the group stages, Spain goalkeeper Sandra Panos said her team "can play with any team in the world," and so it proved on a balmy evening in Reims.
"I really feel that we all should be proud of what we did," Vilda said after the match. "I am very proud indeed. In terms of competitiveness, we gave the best team in the world a run for their money.
"It was a great effort on part of all the players. We're going to grow from this defeat, and I'm really sure all the players on the team have ensured their future."
For the US, focus will now turn to Friday for a heavyweight contest many would deem a worthy final. France hasn't always been convincing on home soil in recent weeks, coming through in extra-time against Brazil, but Les Bleues, ranked fourth in the world, undoubtedly have some of the world's finest players at their disposal.
"This is the game that everyone had circled," Rapinoe said of the tie. "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.
"It's incredible for the women's game. You have two heavy hitters meeting in the knockout round. This is everything you want from these two sides."
Sweden sets up Germany clash
In Monday's other game, Sweden set up a quarterfinal clash with Germany on Saturday after defeating Canada 1-0 in Paris.
After an uninspiring first half, it took 55 minutes for the game's first real chance to emerge when Sweden counterattacked dangerously from its own half.
A perfectly weighted pass from Kosovare Asllani found Stina Blackstenius, who finished via a deflection from Shelina Zadorsky to score her first World Cup goal.
With Sweden holding a slender advantage, the game sparked into life. Asllani almost turned from hero to villain after a consultation with the video assistant deemed she had handled in the area.
Hedvig Lindahl, however, came to her rescue when she produced a stunning save low to her right to keep out Janine Beckie's penalty.
Beckie's effort was the 22nd penalty of the tournament, the same number seen in the whole of the previous World Cup in 2015.
There was more drama to come -- Sweden was awarded a penalty which was chalked off for an earlier offside, before Desiree Scott cleared a shot from Asllani off the line -- but no more goals as Sweden marched into its seventh quarterfinal.