Veteran keeper Gianluigi Buffon then saved the crucial fifth penalty from Walter Gargano to secure the play-off win for the Italians.
Italy also had to survive for 10 minutes in extra-time with only 10 men after Riccardo Montolivo was sent-off for a second bookable offence.
Uruguay’s talisman Forlan tested Buffon early on with a well-struck free-kick which forced the veteran into a comfortable stop.
The Italians were stretching their opponents well on the counter-attack and the lung-busting runs from Antonio Candreva of Lazio were creating their best chances.
After 15 minutes, he timed his run into the box to good effect and was found by De Sciglio, but the midfielder’s left-foot shot was stopped by Fernando Muslera.
Three minutes later, Candreva picked up a neat pocket of space in the central midfield area and he blazed his 30-yard shot over.
Eventually, the Italians found the net in bizarre circumstances.
Diamanti's sweeping, over-hit free-kick struck the upright, rebounding off Muslera’s back and over the line, helped by defender Astori.
After much deliberation from FIFA, who had installed goalline technology into Confederations Cup venues, Astori was awarded the goal – his first international strike.
Uruguay made encouraging steps back into the game with Buffon denying Luis Suarez and Maxi Pereira from close range.
But the ball was in the net for the South Americans on the half hour point, as Cavani nodded in a Forlan free-kick from an offside position.
Lively Italian striker Stephan El Shaarawy steamed up the other end within a few minutes and stung the palms of Muslera from a dipping half-volley.
Uruguay, though, were resorted to long-range shots, as the Italians comfortably saw out the closing exchanges of the first-half.
There was injection of pace in the South Americans by the restart and it wasn’t long before Oscar Tabarez’s side levelled matter on 57 minutes.
The Uruguayans sprung on the counter-attack to catch the Italians on the back-foot with Walter Gargano leading the charge.
He picked out Napoli frontman Cavani with a lovely pass and the striker was composed enough to find the opposite corner with his right-foot.
Italy’s slackness in midfield created a terrific break for the Uruguayans on 67 minutes with Forlan being denied by some outstanding goalkeeping from Buffon.
The Juventus keeper, who was making his 133rd international appearance, saved well from Forlan initially, before he reacted instinctively to deny the former-Atletico Madrid striker from hitting in the rebound.
In spite of Andrea Pirlo’s absence, there was still potential for some individual brilliance from free-kicks with two goals inside a crazy five minutes.
Firstly, Diamanti stepped up for the Italians with a sweetly-struck left-footed free-kick from 25 yards out which beat Muslera all-ends up.
Still, he was upstaged by Cavani’s 35-yard set-piece which sailed past a questionable Buffon and found the top corner on 78 minutes.
Uruguay ended the 90 minutes on top, although, failed to create any goalscoring opportunities against a fatigued Italian side.
The heavy legs were evident as neither side had the energy to build any momentum inside extra time.
But with 10 minutes to play in extra time, Italy were cut to 10-men when Montolivo was shown his second yellow card for a professional foul on Suarez.
Despite his best efforts, Cavani could not trouble Buffon from two efforts towards the end of the extra 30 minutes, as the game went to penalties.
The Italians scored three of their four spot-kicks and helped by Buffon, who saved from Forlan, Caceres and Gargano, Prandelli’s side secured third-spot.