Spain set up a quarter-final meeting with England at Euro 2022 after Marta Cardona's late goal secured a 1-0 win over Denmark on Saturday.
A first defeat since 2019 to Germany in their second group game meant Jorge Vilda's side needed a point to avoid an early exit.
La Roja were made to endure a nervous night at the Brentford Community Stadium until Cardona's 89th minute looping header made sure of their place in the last eight.
Spain's status as favourites was rocked by the loss of Ballon d'Or winner Alexia Putellas and all-time top goalscorer Jennifer Hermoso before the tournament began.
And they will need to improve markedly if they are to upset an England side that scored 14 goals without reply in the group stages on Wednesday.
Denmark's 4-0 thrashing at the hands of Germany in their opening game meant the Euro 2017 finalists needed to win due to their inferior goal difference.
Despite Spain's dominance of possession, the Danes had their chance to spring an upset nine minutes from time when substitute Nadia Nadim's fierce shot was turned over by Sandra Panos.
Vilda was growing increasingly frustrated on the sidelines as nerves appeared to be getting to his side as the final whistle approached with uncharacteristic sloppy passes offering Denmark hope.
But Spain finally got the breathing space they desired when Olga Carmona's cross was met by her Real Madrid teammate Cardona.
"That goal is for everyone," said Cardona, who dedicated her goal to Virginia Torrecilla, who is also absent from the tournament after recovering from a brain tumour.
"It is for Virginia, for Jenni, for Alexia and those that weren't able to come.
"The group stage is very difficult and now we can really go for it."
Germany were already guaranteed to win Group B, but kept their 100 percent record intact with a 3-0 win over Finland in Milton Keynes.
Sophia Kleinherne broke the Finns' resistance five minutes before half-time when the Eintracht Frankfurt midfielder headed home Giulia Gwinn's cross.
Alexandra Popp then grabbed her third goal in as many games after the break before Nicole Anyomi's precise finish rounded off the scoring.
The eight-time winners will face Austria in the last eight in London on Thursday
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ