Scotland had to settle for a draw with Spain in the first leg of their Euro 2013 play-off at Hampden.
Kim Little fired the hosts ahead from the penalty spot on 26 minutes following a handball incident.
But Adriana Martin knocked in a loose ball soon after when Gemma Fay fumbled a shot from Sonia Bermudez.
Fay made amends with a great double save to deny Martin from the penalty spot in the closing minutes of the first half.
Spain's Adriana Martin celebrates her equaliser at Hampden Park
But Anna Signeul's side face a major task in Madrid on Wednesday if they are to qualify for the finals in Sweden next summer after being held by a very good Spain side.
The Scots might have gone to Spain with a valuable but narrow lead if Swiss referee Ester Staudli had given a third penalty of the game late in the second half with the home side pushing for the winner.
It was the women's debut performance at the national stadium and free admission helped to attract 4058 spectators - a record attendance for the team.
What they saw was Spain dominating most of the opening 45 minutes against a Scottish side looking to go one better than four years ago, when they lost to away goals to Russia at the same play-off stage.
However, it was Scotland who took the lead on 25 minutes after a Jenny Beattie header from a corner came back off the post and the assistant referee spotted a hand ball in the box and referee Staubli gave the penalty.
"Mintlaw Miracle", as the match programme described her, Kim Little made no mistake from the spot for her 25th international goal.
With Spain playing a confident, passing game, it was no surprise when Chelsea striker Adrianna Martin equalised five minutes later after Scotland goalkeeper Gemma Fay should have done better with a Sonia Bermudez shot.
If Fay was at fault there, she more than made amends right on half time with a brilliant double save from Martin's penalty when the assistant referee saw Rhonda Jones handle in the box.
The second period was much more cagey than the first, with Spain's Jennifer Hermoso and Scotland's Emma Mitchell both having half chances.
Hampden erupted when referee Staubli turned away a major Scotland claim for a penalty on 76 minutes, when it did look like Ruth Garcia handled in the box.
This time the referee said no and the home fans were denied the win they wanted to make this new Hampden experience just that little bit better.
Signeul remains confident her side will score in Madrid, but that is the least of what they will have to do if the passion of this performance is not going to be outdone by real pain in Spain.
Scotland coach Anna Signeul
: "If she sees the first two penalties, why did she not give the third?
"Although I believe she did not see either of the first two and it was her assistants who gave the awards."
Fay, Jones, Small, Love, Lauder, Little, Sneddon, Beattie, J. Ross (Mitchell 59), Corsie, Evans (Grant 83). Subs: Lynn, McSorley, L. Ross, Fernon, Brown.
Tirapu, Nicolau, Garcia, Bermudez (Dieguez 90), Martin (Romero 83), Vilanova, Hermoso, Meseguer, Ibarra, Torrejon, Vazquez (Garcia 75). Subs: Pons, Landa, Boquete, Calderon.