Cesc Fabregas gave the European and world champions the lead after 15 minutes at the Khalifa Stadium but Cristian Rodriguez levelled for Oscar Tabarez's side on the half-hour mark.
Pedro Rodriguez restored Spain's lead just after half-time and then secured the victory with a close-range finish with 15 minutes to go.
The game was coach Vicente Del Bosque's 68th game in charge of the national side, which took him level with Ladislao Kubala as the man who has coached Spain for the most games.
The match also saw centre-back Carles Puyol make his 100th appearance for Spain and he captained the side to mark the occasion, while Cesar Azpilicueta, Isco and Mario Suarez all made their international debuts.
Spain started the brighter of the two sides but took the lead in fortuitous fashion. Fabregas received the ball in plenty of space from Juan Mata and tried his luck from 30 yards out, but was amazed to see his shot go through the hands of Uruguay goalkeeper Fernando Muslera and drop into the net.
Uruguay responded well and put pressure on Spain immediately, with Victor Valdes and Jordi Alba having to react quickly on different occasions to clear the danger.
But Cristian Rodriguez eventually made the pressure count and grabbed the equaliser, receiving a through-ball by Martin Caceres and using his strength to turn Puyol and then shoot past Valdes.
The Copa America holders could even have taken the lead before half-time but Sergio Ramos made an important tackle on the edge of the area to deny Edinson Cavani a clean run on goal.
Puyol was replaced by Barca team-mate Gerard Pique at half-time and the substitute had the desired impact within little more than five minutes of coming on, providing a pass from the edge of the area to Pedro who shot past Muslera into the far corner to put the Spaniards in front again.
Tabarez's side's best chance to equalise came when Cavani fired a shot at goal from just inside the area, but Valdes tipped the ball away for a corner.
With half an hour remaining the lively Andres Iniesta made way to allow 20-year-old Isco to make his first appearance for his country, and the Malaga midfielder showed he has plenty to offer in the future as his energy and skill meant Spain were no less dangerous without Iniesta.
Spain rounded off the victory with a goal to saviour with 15 minutes remaining. Substitute David Villa received the ball from outside the area and passed to Fabregas on the left-hand side. The former Arsenal man was under pressure from a defender but swung in a perfect cross to the back post which was met by Pedro, who could not miss from barely five yards out.
Villa missed a chance to increase the lead in stoppage time when his close-range effort was saved by Muslera, but Spain will have been more than satisfied with their performance and the result.