Spain defeat Italy 7-6 on penalties
Substitute Jesus Navas converted the winning penalty past Gianluigi Buffon after Italian defender Leonardo Bonucci skied the 13th penalty of the shootout with the score level at 6-6 at a spellbound Estadio Castelao.
All the previous 12 penalties had been converted with players from both sides displaying nerves of steel as the tension increased.
Antonio Candreva began what was effectively the fourth act of a classic match when he planted the ball past Spain goalkeeper Iker Casilla and after that, 11 others stepped up and dealt with the mounting pressure before Bonucci's kick ended up in Row Z.
The Spanish players found their last dregs of energy to celebrate wildly as they set up a final against Brazil on Sunday at the Maracana in Rio de Janeiro.
Brazil, who beat Uruguay 2-1 in Wednesday's semi-final will be looking for their third successive Confederations Cup title and fourth overall.
The tournament, which is being used as a test event for next year's World Cup finals in Brazil, has been shrouded in controversy with the matches overshadowed by riots and protests about social issues and the cost of hosting the World Cup.
The atmosphere in the stadia, however, has taken soccer fans' minds off the chaos outside and Thursday's semi-final between the Euro 2012 finallists was no different as the game fell into four distinct acts.
Italy dominated the first half before Spain got back into the game in the second.
The world champions then asserted themselves in extra time, while the denouement was the penalty shootout that appeared as if they could last all night until Bonucci's miss.
"They were on top, especially in the first half, but we showed our strength and in the second half, we ironed out some problems and the match became more balanced," Spain coach Vicente Del Bosque said.
"We were the better team in extra time and we had the luck in the shootout, but that's the way it goes. You can't rehearse penalties, you just have to go for it."
Italy coach Cesare Prandelli felt his side, who were hammered 4-0 by Spain in the Euro2012 final, had moved on since then.
"This match was a great test for us and we passed it, despite the result," Prandelli said.
We were convinced how we needed to play in both tactical and technical terms and we did that especially in the first half.
"Spain are ahead of us and have been forging their path for years now, but we must forge our own path and keep going.
"I think we are on the right track."
Italy were disadvantaged in the build-up to the match when striker Mario Balotelli went home injured and he was missed in front of goal, especially in the first half when Italy wasted three good scoring chances all from headers.
Christian Maggio had the best chance after 36 minutes when he headed straight at Casillas, but Prandelli's decision to switch his formation to 3-5-2 with a five man midfield anchored by Andrea Pirlo gave them the early advantage.
The Italians also stifled much of the usual creativity from Spain midfielders Andres Iniesta and Xavi and their first half chances were limited to just Pedro firing wide after two minutes and Fernando Torres shooting wide after 37 minute.
Emanuele Giaccherini hit the post for Italy in extra time and Xavi did the same for Spain four minutes before the final act unfolded in the shootout.