Bonaventure Kalou got the second goal for Ivory Coast
Ivory Coast were beaten 3-2 by fellow World Cup finalists Spain in Valladolid on Wednesday.
Substitute Juanito Gutierrez scored an 85th-minute winner for coach Luis Aragones to extend his unbeaten record to 19 games.
The Ivorians twice took the lead with goals by Abdul Kader Keita and substitute Bonaventure Kalou in the first match between the countries, played in icy conditions at Jose Zorrilla stadium.
David Villa and substitute Jose Antonio Reyes scored Spain's other goals in the World Cup warm-up match for both sides.
Spain, playing its first game since eliminating Slovakia in the World Cup playoffs in November to reach the finals, gave Cesc Fabregas his debut and Arsenal's 18-year-old midfielder responded by producing several incisive passes.
However, the Elephants, who lost on penalties to hosts Egypt in the final of the African Cup of Nations earlier in the month, scored in the 13th minute when Keita seized on a
loose ball after Didier Drogba had headed Kanga Akale's cross from the left.
Spain equalised 10 minutes later after a move down the right involving Cesc and Luis Garcia.
The ball fell to Villa and, although his initial shot was parried by goalkeeper Jean-Jacques Tizie, the striker headed the rebound home.
Ivory Coast regained its lead when Kalou, who had started the second half as a substitute, struck instantly with a long shot past goalkeeper Iker Casillas.
Villarreal's Brazilian-born midfielder Marcos Senna appeared in the 58th minute for his Spanish debut, 15 minutes before Reyes scored the host's second equalizer
with a rising right-footed shot.
Spain surged forward in search of the winner and substitute Juanito obliged by heading home from Antonio Lopez's corner.
"In the first half we began a little weakly and struggled against two very good forwards, Drogba and Arouna Kone. We improved in the second when Sergio Ramos played
better," Aragones said.
"Ivory Coast is a very strong team. It should do well in the World Cup. And it's getting better every day.
"But against a physically very strong team we dominated the game and created more opportunities. People will have enjoyed the game."
Ivory Coast coach Henri Michel said the result was acceptable.
"Without being a great game, we got a decent result. They scored three goals which we could have avoided. But we didn't have our normal defense playing," Michel said.
"Spain is a young team which hasn't lost for two years. It's very important for us to play against these good teams to prepare for the World Cup in the best possible way."
With Spain hit by an surge of racist taunting of black players during matches, the two sets of players before the game lined up in front of a banner proclaiming 'Everyone
The Ivorian national anthem was then applauded by crowd of 20,000.
Ivory Coast is due to face Argentina, Serbia-Montenegro and Netherlands in Group C of the World Cup.