Goals from Paco Alcacer and Cesc Fabregas saw Spain come from a goal down to beat Costa Rica 2-1 in a friendly on Thursday.
The European champions made a slow start in Leon as Johan Venegas finished off a swift counterattack to put Costa Rica ahead inside five minutes.
Paulo Wanchope’s side were unable to consolidate the lead, though, as Spain soon turned on the style and Alcacer scored his fourth international goal in just six Spain appearances.
Chelsea midfielder Fabregas then put the finishing touch on a well-worked move to deservedly put Spain in front on the half-hour mark and that proved to be the winner.
The hosts, who had lost their past three friendly matches, had chances to increase their lead after the break, with Sergio Ramos twice denied brilliantly by Real Madrid team-mate Keylor Navas in the Costa Rica goal.
Spain will now switch their attention to the more important matter of Sunday’s Euro 2016 qualifying fixture in Belarus, with Vicente del Bosque’s side three points adrift of Group C leaders Slovakia. Costa Rica have one last warm-up match against Mexico before next month’s Concacaf Gold Cup.
Costa Rica stole ahead against the run of play in just the sixth minute. Joel Campbell led a swift counter down the left before squaring to Venegas, who fired low first time past David de Gea.
The lead last just two minutes, though, as Spain hit back from the next attack.
Fabregas’ through ball picked out the clever run of Alcacer and the Valencia forward kept his cool when one-on-one with Navas to place his shot into the bottom right-hand corner.
With their tails up, Spain pressed for a second and Mikel San Jose should have done better when he fired a half-volley over the crossbar from 10 yards.
The pressure told on the half-hour mark as Spain moved ahead for the first time.
Barcelona new boy Aleix Vidal’s cross from the right picked out Nolito and the winger volleyed a pass into the path of Fabregas, who side-footed home from close-range.
Vidal appeared to pick up a knock before the break and was replaced by former Sevilla team-mate Vitolo.
Spain remained in the ascendancy in the second half and only a superb point-blank save from Navas denied Ramos from heading home a third.
Ramos was left flabbergasted when Navas repeated the trick with a fine reflex stop from his close-range half-volley just before the hour. The centre-back was substituted shortly after and shared a warm embrace with an adversary whose goal he normally guards – though his replacement, Gerard Pique, was booed by large sections of the crowd.
Santi Cazorla was next to be denied by Navas, the Arsenal man having run onto a sublime flick from David Silva, before Koke had an audacious close-range rabona effort charged down.
Spain’s failure to find a third goal almost proved costly when Bryan Ruiz flashed a half-volley over the crossbar in the closing stages, but Del Bosque and his side can travel to Borisov in high spirits.