Caroline Weir's first-half strike was not enough to send Scotland into the knockout stages of Euro 2017 despite the fact her smash-and-grab goal settled a 1-0 victory over Spain in Deventer.
Anna Signeul, who will now step down as Scotland manager, needed both her team to beat Spain by at least two goals and Group D toppers England to defeat Portugal in Tilburg, which they did 2-1.
Liverpool midfielder Weir's goal against the run of play settled a one-sided game in Scotland's favour while Signeul's ladies were lucky to retain goalkeeper Gemma Fay on the pitch following an ill-judged foul.
Spain started brightly with Fay, on the occasion of her 203rd cap, forced to tap a dangerous Marta Torrejon free-kick against a post and out.
Las Sonadoras grew in confidence and by the half-hour mark were really turning the screw, with Irene Paredes, Jenni Hermoso and Vicky Losada all going close before Fay endured a real sticky moment.
Flying out of her box to deny the onrushing Alexia Putella, she used her gloves to clear the ball. The Perth-born stopper somehow avoided a red card, seeing only yellow for the foul.
Scotland took the lead totally against the rhythm of proceedings as half-time approached, Spanish keeper Sandra Panos making a hash of a clearance and allowing Weir to clip home the clincher.
It was all Spain after the break and Scotland were up against it in their mission to not only cling on to the lead but to score the goal that would send them into the last eight.
With extra bodies up front, Spain nearly found the equaliser through Maria Paz, who dragged Amanda Sampedro's assist just wide.
Hearts were in mouths late on when four Spanish forwards raided the Scottish box, with Ifeoma Dieke providing a crucial block to stop the ball falling to one of at least three red-shirted strikers.