The home side looked to be heading for a frustrating draw until the Manchester City midfielder, who had replaced Xabi Alonso 10 minutes earlier, poked the ball past David Ospina in the 86th minute.
Silva service: Spain midfielder celebrates scoring the winner
David Villa, who is Spain's joint leading goalscorer on 44 with Raul, had come closest to scoring when he struck a shot against the post in the 15th minute and then missed the open goal from a tight angle from the rebound.
Victory for Spain ends a poor run of form in friendlies. They slipped to a 4-1 defeat in Argentina in September and a 4-0 loss in Portugal two months later after drawing 1-1 with Mexico in August.
Denmark 1 England 2: Young boosts Fabio as Three Lions complete friendly fightback Scotland 3 Northern Ireland 0: Captain Kenny Miller inspires Dublin stroll
Explore more:People: David Villa, David Silva, Xabi Alonso Places: Spain, Argentina, Portugal, Mexico, Colombia