Spain set up a quarterfinal 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 team needed a point to avoid an early exit.
La Roja was made to endure a nervous night at the Brentford Community Stadium until Cadona's 89th-minute looping header made sure of a place in the last eight.
Spain's status as favorites was rocked by the loss of Ballon d'Or winner Alexia Putellas and all-time top goalscorer Jennifer Hermoso before the tournament began. And it will need to improve markedly if it is to upset an England team that scored 14 goals without reply in the group stages on Wednesday.
Denmark's 4-0 thrashing at the hands of Germany in its opening game meant the Euro 2017 finalist needed to beat Spain due to its 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 Cardona. her Real Madrid teammate.
"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 tumor. "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 was already guaranteed to win Group B, but kept its 100 percent record intact with a 3-0 win over Finland in Milton Keynes.
Sophia Kleinherne broke the Finns' resistence five minutes before halftime 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.
German, eight-time Euro winner, will face Austria in the last eight in London on Thursday.
© Agence France-Presse