Llorente denies Scotland draw
Villa's penalty gave the visitors a half-time 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 half-time 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, Capdevila 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."