"I think everybody was waiting for this Confederations Cup final to be Spain vs. Brazil," Spain captain Iker Casillas said. "I think the two teams that deserve to play the final are actually playing it."
Jesus Navas scored the decisive penalty kick after a draining match made more difficult by heat and thick humidity.
Nobody missed in the shootout until Italy defender Leonardo Bonucci shot over the bar to give Navas an attempt at the winner. The recently signed Manchester City midfielder coolly beat goalkeeper Gianluigi Buffon to end a top-class battle and send Spain to another major final.
While calling his squad "lucky" to win, Spain coach Vicente del Bosque was not about to concede the final due to fatigue even though Spain has one less day of rest than Brazil, which beat Uruguay 2-1 Wednesday.
"We have to now consider what we have to do in the three days to recover. And we will definitely stand up to Brazil in the Maracana," the manager said. "The players should feel just as happy as kids playing in the Maracana. They have won a lot, but they want to win in the Maracana.
Italy's Emanuele Giaccherini hit a post in the 93rd minute and Buffon deflected Xavi Hernandez's kick off a post in the 115th. Those were the best chances in extra time, and then came 12 perfect penalties before Bonucci missed.
"We were lucky in the penalty shootout," Del Bosque said. "It was a very difficult match for us. ... It was a marvelous team effort by both teams. It was a clean and sporting match that was played under very difficult climatic conditions."
Spain, winner of the 2010 World Cup and the 2008 and 2012 European Championships, went second in the shootout. The 35-year-old Buffon and 32-year-old Casillas, among the world's elite goalkeepers for more than a decade, exchanged handshakes with English referee Howard Webb before the shootout and then hugged each other.
Antonio Candreva, Alberto Aquilani, Daniele De Rossi, Sebastian Giovinco, Andrea Pirlo and Riccardo Montolivo all converted their kicks for the Italians.
Xavi, Andres Iniesta, Gerard Pique, Sergio Ramos, Juan Mata and Sergio Busquets made their kicks for Spain.
After Bonucci failed, Buffon dived to his right and Navas sent the kick past his outstretched arm.
Spain beat Italy 4-0 in last year's Euro final and defeated the Azzurri 4-2 on penalty kicks after a 0-0 tie in the 2008 Euro quarterfinals.
"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."
Italy, missing injured Mario Balotelli, dominated the first half. Spain, without injured Cesc Fabregas and Roberto Soldado, settled down and bolstered by the second-half insertion of Navas and Mata, wound up with 54 percent possession and a 19-13 advantage in shots.
Italy will face Uruguay in the third-place match in Salvador, also Sunday.
Before kickoff, about 5,000 anti-government protesters battled police about 1 mile from the stadium.
These were the latest in a series of nationwide protests that have hit Brazil since June 17. Demonstrators, expected to turn out again Sunday, are angered about corruption and poor public services despite a heavy tax burden. Protesters also are denouncing the billions of dollars spent to host the World Cup and the 2016 Olympics in Rio.