Substitute Fernando Llorente scored with 11 minutes left to keep up Spain's flawless start to UEFA EURO 2012 qualifying Group I after Scotland had fought back from two goals down.
David Villa equalled Raúl González's record of 44 goals for Spain with a penalty just before the break and Andrés Iniesta looked to have put the result beyond doubt when he added a second soon after half-time. However, Steven Naismith with his first for Scotland and an own goal from Gerard Piqué threatened to give the home side a point until Llorente – left out of the starting lineup despite scoring twice in Friday's 3-1 defeat of Lithuania – claimed the winner within three minutes of his introduction.
Having taken a cautious approach in the 1-0 loss in the Czech Republic on Friday, Scotland manager Craig Levein brought back striker Kenny Miller and gave defender Phil Bardsley his debut with Alan Hutton injured. In front of a capacity crowd Scotland sought to exert some early pressure but the visitors were the first to threaten through Villa, shooting over after being picked out by Iniesta.
Within two minutes Villa tested Allan McGregor with a header from a Sergio Ramos cross and the keeper then rushed from his line to block David Silva's goal-bound effort. Scotland broke and it took the combined efforts of Carles Puyol and Piqué to clear James Morrison's effort off the line from Darren Fletcher's cross. However, it proved to be a temporary respite and on the half-hour McGregor again denied Villa from point-blank range.
The opening goal seemed inevitable and a minute before the break Spain were awarded a penalty after Whittaker handled Ramos's shot in the box. Villa stepped up and although McGregor got fingertips to the ball, the away side were ahead.
Ten minutes after the restart Spain doubled their advantage when Iniesta slotted in from close range after Santiago Cazorla's shot had rebounced off Stephen McManus. Scotland, however, had hope three minutes later, Naismith turning in Miller's cross, and Hampden erupted when Piqué diverted Morrison's centre past Iker Casillas.
However Llorente, whose starting place had gone to Xabi Alonso, was brought on and swiftly side-footed in Joan Capdevila's cross from the left. Scotland ended with ten men when Whittaker picked up a second yellow card for a challenge on Ramos and they are back in third, two points behind the Czech Republic and five adrift of Spain having played a game more than both.