Xavi and Juan Mata combined to make sure world and European champion Spain was not embarrassed by Lithuania on a difficult surface in Kaunas as their side won 3-1.
Xavi, embarking on his second century of appearances for Spain after winning his 100th cap in its Euro 2012 qualifier against the Czech Republic, opened the scoring after 20 minutes.
But Marius Stankevicius levelled 11 minutes after the break and it needed the intervention of substitute Mata, who brought about an own goal from Tadas Kijanskas after 70 minutes and finished himself six minutes from time, to decide things in Spain's favour.
The result extended Spain's 100 percent start to its qualifying fixtures, and ensured it kept its lead at the top of Group I at six points over the Czech Republic, which beat Liechtenstein earlier.
Such was the difficult nature of the pitch that there was some uncertainty ahead of kick-off as to whether the match would go ahead.
But go ahead it did, and it was Spain striker David Villa who was quickly to the fore.
Villa had stolen the headlines against the Czech Republic when he notched his 45th and 46th international goals to become Spain's all-time leading scorer.
And he was quickly hunting for number 47, but his shot from 20 yards was held by Lithuania goalkeeper Zydrunas Karcemarskas.
But he did make a decisive contribution in the 20th minute as he and Barcelona team-mate Xavi switched their usual roles.
For a change it was the striker who played in the midfielder and Xavi struck the ball home from 25 yards.
Javi Martinez had the opportunity to double the lead in the 27th minute but his shot was too close to Karcemarskas, who held on.
The host had chances of its own before the break, with Darvydas Sernas failing to find the target from out wide just before the half-hour mark and Mindaugas Panka bringing a save out of Iker Casillas with an ambitious strike from 30 yards as half-time loomed.
Villa was withdrawn eight minutes after the restart, replaced by his former Valencia team-mate David Silva.
And the Manchester City man had been on the pitch barely three minutes when his team was pegged back.
Deividas Semberas on the left found Stankevicius, whose 25-yard effort was good enough to beat Casillas.
That spurred Spain into action and when Tomas Danilevicius fouled Fernando Llorente 25 yards from goal, Xabi Alonso drilled a free-kick towards goal, with Karcemarskas got enough on to turn behind.
Spain coach Vicente Del Bosque brought Mata on in the 66th minute and it proved to be an inspired change as he was involved in Spain's second four minutes later.
The Valencia winger advanced down the left and played the ball into the centre where Kijanskas, under pressure from Llorente, headed into his own net.
Alonso's free-kick was blocked by Semberas four minutes later after Andrius Skerla had fouled Llorente.
But a third goal did come, with Xavi this time assuming the more familiar role of creator as he played in Mata to finish from 12 yards to cap his match-changing cameo.
Scotland created a huge upset in 2014 FIFA World Cup qualifying after inflicting a first defeat on high-flying Croatia in Zagreb.