Leon - 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.
He thanked Colombian singer Kevin Roldan who performed at a birthday party for Cristiano Ronaldo that created controversy at Real as it followed a heavy La Liga defeat by Atletico Madrid.
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.