A spirited Scotland comeback from two goals down ultimately proved futile as Spain left Hampden with three points in their Euro 2012 Group I qualifier.
David Villa slotted home a penalty on the stroke of half-time after Steven Whittaker was punished for handball.
On 55 minutes Andres Iniesta side-footed home from 12 yards before a Steven Naismith diving header and a Gerard Pique own-goal levelled the tie.
But a Stephen McManus error allowed Fernando Llorente to tap in the winner.
The task facing the Scots was considerable - the Spaniards' line-up differed from the 11 who started the World Cup final in only two positions.
Pedro Rodriguez and Xavi Hernandez were absent - along with Cesc Fabregas and Fernando Torres - and in their place came Manchester City's David Silva and Santi Cazorla of Villarreal.
Andres Iniesta side-foots Spain's second into the net
For the home side, Craig Levein abandoned the controversial 6-4-0 formation of Friday's 1-0 defeat by Czech Republic and recalled Kenny Miller to lead the attack in a 4-5-1 set-up.
When the Scots won a first-minute corner the Tartan Army roared its approval to remind the world and European champions that they would not get everything their own way.
But Spain demonstrated their threat when Villa escaped central defenders Stephen McManus and David Weir to latch on to a speeding ball from midfield, but his shot went over the bar from 18 yards.
Moments later he again peeled away from his markers and headed into the arms of grateful goalkeeper Allan McGregor.
Players were all heroes - Levein
The Scots steadied themselves and had a glorious chance to take the lead when Darren Fletcher cut the ball back for the unmarked James Morrison 10 yards out, whose blasted shot was blocked a yard from Iker Casillas's goal.
On the half-hour mark Sergio Busquets rifled a shot at goal, which fell to Villa who spun his marker and shot from close range. Instinctively, McGregor threw up an arm and made a terrific save.
Three minutes later Villa raced through a static dark blue defence to collect a visionary chip by the elegant Xabi Alonso but uncharacteristically failed to control the ball with only the keeper to beat.
Playmaker Iniesta was next to try his luck, his goal-bound right-foot volley deflected over by McManus.
Then, by way of relief, Miller was sent sprinting down the inside-left channel and he and Dorrans found themselves two against two in acres of space. However, the chance was wasted by Miller's inaccurate pass which caught a defender's foot.
On the stroke of half-time, Whittaker was penalised by Swiss referee Massimo Busacca, when the Rangers full-back misjudged a cross from the left, which floated over his head and on to the foot of Ramos. The Real Madrid defender whacked his shot off the raised arm of Whittaker and Villa hit the resultant penalty past McGregor to give the visitors the lead.
Blackpool's Charlie Adam has enjoyed a few seasons jousting with giants, and he came on for the second 45 for Lee McCulloch, whose efforts to keep in touch with the fluent Spanish midfield play resembled a thundering bull being teased by matadors.
Sunderland right-back Phil Bardsley was making his international debut and it was from that position that the cross came for the first chance after the break.
Villa took the ball on his chest and sent a volley to McGregor's left, which he expertly kept out.
Naismith wheels away after his diving header reduced Spain's two-goal lead
However, he was helpless in 55 minutes when Iniesta side-footed his ninth international goal past him from 12 yards, the Spaniard the first to react to a loose ball in a frantic box.
Scotland hit back immediately. Miller worked his way from the right and clipped an inviting cross between defenders Pique and Ramos and keeper Casillas, where Naismith dived to head into the net from six yards.
With the Spaniards passing against a backdrop of noisy fans, Levein's side, incredibly, drew level.
Fletcher and Morrison combined with the type of incisive one-two one associates with La Furia Roja, and when the West Brom midfielder crossed for Miller to tap the ball home, Fletcher's former Manchester United team-mate Pique slid in to knock the ball into his own net.
Pablo Hernandez came on for Cazorla and was the recipient of a delightful pass by Villa and ought to have done better with his shot, an uncertain effort which McGregor was well placed to save with his feet.
Dejection for outstanding McGregor
As Jamie Mackie prepared to replace Dorrans, the champions moved in front once more. McManus inexplicably misjudged a looping ball from the left wing and substitute Llorente gratefully side-footed the ball past McGregor with 11 minutes to go.
Whittaker was sent off with a minute remaining for a second bookable offence as the home side tried desperately to get hold of the ball.
Despite the defeat, it was a fine effort by Scotland, who are now in third place in the group on four points from a possible 12. Spain have maximum points from their three games.
Scotland: McGregor, Bardsley, McManus, Weir, Whittaker, Dorrans (Mackie 81), Darren Fletcher, McCulloch (Adam 46), Morrison (Maloney 87), Naismith, Miller. Subs Not Used: Gordon, Caldwell, Berra, Steven Fletcher.
Bookmark with:
What are these?