Fernando Torres struck an injury-time winner as Spain concluded their World Cup build-up with a hard-fought 2-1 victory against fellow qualifiers Croatia in Geneva.
The Atletico Madrid star made amends after missing an earlier penalty by netting a fine individual effort with time almost up.
Croatia took the lead in the 14th minute when Spain defender Pablo headed Niko Kranjcar's right-wing cross into his own net, despite being under no pressure.
Mariano Pernia, a late call-up to the World Cup party as a replacement for injured Chelsea left-back Asier Del Horno, equalised shortly after the hour mark with a left-footed free-kick which curled around the wall and into the net.
Spain should have gone ahead with 17 minutes to go but Torres' spot-kick was saved by Croatia goalkeeper Stipe Pletikosa.
The penalty was awarded for a push on Sergio Ramos by Josip Simunic.
Torres redeemed himself, however, by bursting through a packed Croatia defence and slotting home from 12 yards in the 93rd minute.