Cesc Fabregas struck the winner as an experimental Spain side came from behind to beat Costa Rica 2-1 in a friendly on Thursday ahead of their Euro 2016 qualifier with Belarus.
Johan Venegas surprised Spain by giving the visitors the lead in Leon after five minutes but Paco Alcacer equalised two minutes later with a clinical finish.
Costa Rica continued to pose a threat on the break but Fabregas slotted in from close range after 29 minutes and Spain had chances to secure a more comfortable win after the break.
Barcelona defender Gerard Pique came on in the second half to whistles from a section of Real Madrid fans in the crowd who were angry at the way he poked fun at their team during celebrations after the Catalan side's treble win this season.
Spain now turn their attention to the Euro 2016 Group C qualifier in Belarus on Sunday. They have 12 points from five games behind Slovakia who lead the way three points ahead.
Vicente del Bosque’s Spain side, who have won the last two Euros, are aiming to bounce back after losing their World Cup crown last year in Brazil where went out in the group stage.
New blood
Aleix Vidal made his debut as Del Bosque continued to bring in new blood and rebuild the Spain team following the retirement of key players like midfielders Xavi and Xabi Alonso.
There was a lack of understanding in defence, though, as Costa Rica took the lead with their first real attack.
Striker Joel Campbell was given plenty of space on the left wing and he rolled a pass to Venegas who fired home.
Alcacer quickly brought Spain level, beating the offside trap and then finishing expertly past keeper Keylor Navas.
Spain had most possession and Fabregas put them in front as he made no mistake after a miscued shot from Nolito fell to him.
In the second half Navas made excellent saves from Sergio Ramos and Santi Cazorla and Spain defender Marc Bartra blazed over from close range.
“I was happy with my performance and that of the team,” Bartra told reporters. “I don’t agree with the whistles (for Pique) as he gives his all for Barca and the national team.”