A solid first-half performance by Scotland was not enough to prevent them losing to group leaders Spain in their top of the table European Under-21 Championship qualifying match.
Scott Gemmill's side went into the game at Tynecastle just three points behind Spain in Group B, having won four of their past five matches.
And Leon King came closest to scoring for the hosts in the first half with a long-range effort, while Scotland did well to keep Spain's dangerous attackers at bay.
However, the visitors started strongly after the break, pressing Scotland deep into their own half, and just before the hour mark Spain finally got the breakthrough.
A short corner resulted in a perfectly curled ball to the back post, where Bournemouth defender Dean Huijsen rose above the Scotland defence to power home his header.
The goal woke Scotland from their slow second-half start, and the hosts got back on the front foot and equalised within a couple of minutes.
Josh Mulligan's bursting midfield run ended with a well-executed pass through the Spanish defence into the path of Dire Mebude, who slid the ball past goalkeeper Alejandro Iturbe.
Spain continued to press, however, and a probing run down the right flank allowed Hugo Novoa to thread a neat pass into Leeds forward Matteo Joseph who, in his first real involvement after coming on as a substitute, found space in the Scotland box to turn the ball home.
Scotland did their best to force their way back into the game, coming close from a stoppage-time corner, but could not find an equaliser.
The result all but ends Scotland's hopes of finishing top of the group. They now travel to Malta on Tuesday before next month’s crucial double-header against Kazakhstan and third-placed Belgium.