Jesus Navas scored the decisive penalty as World Cup holder Spain beat Italy 7-6 in a shootout after extra time ended 0-0, setting up a showdown with host Brazil in the Confederations Cup final.
Nobody missed in the shootout until Italy defender Leonardo Bonucci shot high to give Navas an attempt at the winner.
The recently signed Manchester City midfielder cooly beat goalkeeper Gianluigi Buffon to end a top-class battle and send Spain to another major final.
In draining heat and humidity, each side hit the woodwork in extra time. Emanuele Giaccherini smashed a shot off the post in the 93rd minute and Buffon deflected a shot from Xavi Hernandez off the post in the 115th.
The final will be played Sunday at the Maracana Stadium in Rio de Janeiro. Italy will face Uruguay in the third-place match in Salvador, also Sunday.
In a rematch of the Euro 2012 final, which Spain won 4-0, Italy threatened early on even without the injured Mario Balotelli, relying on counterattacks, while Spain relied on its usual game of short passes and ball possession.
The roles reversed in the second half but it wasn't until extra time that each side produced some of the match's best chances.
"We played a great match. We created and we conceded but we were always in the match," Italy coach Cesare Prandelli said. "They're still ahead of us but we're improving.
"In these conditions, between absences and fatigue, it's nearly impossible to go all the way, but the guys really moved me," Prandelli added.
When English referee Howard Webb whistled the end of extra time in the 120th minute, the crowd inside the Castelao Stadium cheered loudly, applauding two hours of world class football between teams which could not be separated.
Before kickoff, about 5,000 anti-government protesters battled police about 2 kilometers (1 mile) from the stadium.
More protests are expected at Sunday's final of the World Cup warm-up tournament.
Thursdays' were the latest in a series of massive, nationwide protests that have hit Brazil since June 17. Demonstrators are angered about corruption and poor public services despite a heavy tax burden.
Protests are also denouncing the billions of dollars spent to host the World Cup and the 2016 Olympics in Rio de Janeiro.
Sunday is the fourth major final Spain will play in five years, having won the 2008 and 2012 European Championships plus the 2010 World Cup.
Inside the Fortaleza stadium, which appeared full, there was overwhelming support for Italy from local fans, who were perhaps afraid of facing Spain in the final. Spain was booed early on every time it took the ball.
Christian Maggio had the best chance of the first half in the 36th with a header inside the box that Spain goalkeeper Iker Casillas did well to block.
A minute later, Xavi Hernandez set up Spain's only real chance early on but Fernando Torres shot wide.
Reverting to a three-man defense, Prandelli made another tactical move to start the second half, replacing center back Andrea Barzagli with midfielder Riccardo Montolivo and putting De Rossi at the center of the defense.
Seeking to inject some energy into his squad, Spain coach Vicente Del Bosque sent on Navas for David Silva in the 52nd and Navas had the first significant chance of the second half six minutes later with a long, low effort that Buffon controlled.
The roles reversed as the second half wore on, with Italy controlling more and and Spain resorting more to counterattacks. Italy had a series of corner kicks at one point but had trouble producing chances.
Navas threatened in the 92nd with a long shot that appeared to surprise Buffon but the goalkeeper quickly recovered. A minute later, Giaccherini hit the post and then Jordi Alba volleyed high from close range as all of a sudden there was a flurry of chances.
In the shootout, Italy went first and Antonio Candreva, Alberto Aquilani, Daniele De Rossi, Sebastian Giovinco, Andrea Pirlo and Montolivo each converted near perfect penalties for the Azzurri.
However, Bonucci is a center back who rarely, if ever, takes penalties, and his attempt was far over the bar.
Spain matched Italy shot for shot with Xavi, Andres Iniesta, Gerard Pique, Sergio Ramos, Juan Mata and Sergio Busquets each finding the target before Navas stepped up.
Buffon guessed right on Navas' shot but the ball was so close to the striker's left post that the goalkeeper had no chance.
Will Burnley retain their EPL status?