Glasgow: David Villa equalled Raul`s Spain scoring record of 44 but the world and European champions had to withstand a Scotland fightback before Fernando Llorente`s late goal secured a 3-2 win in a Euro 2012 qualifier on Tuesday.
Villa`s penalty gave the visitors a halftime lead at Hampden Park and Andres Iniesta scored a second just after the break.
Scotland coach Craig Levein had been strongly criticised for his striker-less tactics employed in the 1-0 defeat by the Czech Republic on Friday but with striker Kenny Miller back in the fold, the Scots mounted a fightback.
Steven Naismith pulled one back before the hour and Gerard Pique`s own goal pulled the hosts level only for Llorente to fire in a winner 11 minutes from time.
Scotland`s Steven Whittaker was sent off for second yellow in the 89th minute.
Spain are top of Group I with nine points from three matches. Next come the Czech Republic on six with Scotland and Lithuania on four. Liechtenstein are pointless.
Spain coach Vicente Del Bosque said he never feared a defeat despite seeing his team pushed to the limit.
"It was more down to the character and the fighting spirit of the Scottish side. They fought to the bitter end of the game," he told reporters.
"We managed to convert our chances but their comeback was down to hard work and great play by the Scots.
"This win is a massive step. We can relax a bit and put the competition to sleep until March when it starts up again and now we`ve got the Czech Republic as our main rivals to qualify."
Villa passed up several early opportunities but seized his moment a minute before halftime when, after Whittaker had handled a cross from Sergio Ramos, the Barcelona striker beat Allan McGregor from the spot.
Spain looked to have the game wrapped up when Joan Capdevilla`s shot was blocked but Iniesta guided an effort into the corner 10 minutes after the restart.
But just before the hour, the Scots halved the deficit when Kenny Miller crossed for Naismith to head past Iker Casillas for his first international goal. They then drew level when James Morrison`s cross was turned into his own net by Pique midway through the second period.
But with 11 minutes remaining, Capdevilla produced a deep cross that was touched in for Llorente`s third goal in two matches.
Scotland coach Craig Levein cut short a television interview after being questioned about his side`s defeat in Prague.
But Levein maintained that Scotland`s home games against Lithuania and the Czech Republic will be decisive in their bid to reach the finals in Poland and Ukraine.
He said: "It would have have been the easiest thing in the world for them to put their heads down at 2-0 down against the best team that`s possibly ever played here but they didn`t.
"They showed guts and determination. In my eyes we always had to beat the Czech Republic and Lithuania at home and nothing has changed."