By far Scotland’s best performance at Euro 2017 produced a first-ever major championship victory and also a first win over Spain, but it is the defeated side who will go through to Sunday’s quarter-final against Austria.
Scotland needed to win by two, and just came up short despite Caroline Weir’s late first-half goal.
Anna Signeul made five changes to the team which lost 2-1 to Portugal on Sunday. Three were in the back four with Hibernian full-backs Rachel McLauchlan and Kirsty Smith dropping out, along with central defender Vaila Barsley.
Frankie Brown and Chloe Arthur, who started against England, returned, with Rachel Corsie dropping back into central defence.
Glasgow City midfielders Jo Love and Leanne Ross were introduced, while Chelsea teenager Erin Cuthbert was rewarded for her goal in Rotterdam by starting up front instead of Lana Clelland.
The changes left Scotland without a recognised striker as Cuthbert plays in midfield for her club.
It all nearly came unstuck after four minutes.
Frankie Brown gave away a needless free-kick ten yards outside the box, bringing down Alexia Putellis. It was well struck by Marta Torrejon, but even so Gemma Fay didn’t deal with it convincingly and was relieved to see the ball rebound off her right-hand post.
The Scotland captain, winning her 203rd cap and due to retire after the tournament, did better ten minutes later, confidently holding Silvia Mesegeur’s shot from 25 yards. As expected Spain were dominating possession, as they had done in the defeat by England, but despite their slick football were restricted to a couple of long-range shots, both wide of the target.
There were a number of scares for the Scots just after the half hour.
Fay made a hash of catching a high ball but Corsie came to the rescue, heading the ball for a corner. From that the Scotland keeper made a great save to stop Jennifer Hermoso from heading Spain into the lead.
The 25-year-old then produced another good stop, touching another header, this time from Irene Paredes, on to the post. The captain was suddenly having an eventful evening, and that was emphasised when she ran out of her box and handled the ball to stop a Spanish attack. Czech referee Jana Adamkova somehow decided Fay hadn’t stopped an obvious goalscoring opportunity and showed a yellow, instead of red, card.
It looked to be only a matter of time before there was a goal – and remarkably it fell to Scotland. Cuthbert challenged Sandra Panos for a Leanne Crichton through ball and when the Spanish keeper failed to clear it was picked up by Weir. The Liverpool player still had plenty of work to do, but she kept her composure to give Scotland an unlikely interval lead.
Signeul made an attacking change at the start of the second half with Clelland coming on for Ross, and Scotland almost immediately nearly got the second they needed. Weir swung over a corner from the right, but Crichton’s effort at the far post failed to hit the target.
It was a huge opportunity and soon Spain were back on the attack looking for the equaliser that would assure them a place in the quarter-finals.
Substitute Maria Paz came closest with a shot which went narrowly past the post, but the biggest escape came midway through the half when Silvia Meseguer hit the bar with a powerful shot.
With England beating Portugal in the other Group D game there was all to play for and both sides knew it as the game entered a tense last 20 minutes with Spain still doing most of the attacking.
They looked as if they must score with ten minutes left, but Fay and Ifeoma Dieke made goalline saves from Putellas and Paz.