To beat Spain, Cesare Prandelli joked before what turned out to be an epic FIFA Confederations Cup semifinal that Italy might have needed a second ball on the pitch. More accurately, the Azzurri were short a penalty taker or two.

Spain survived a scare against Italy on Thursday after outlasting the Azzurri 7-6 in a penalty shootout at the Estadio Castelao in Fortaleza, Brazil. With the victory, Spain moved within one win of yet another international title, which will be at stake Sunday against hosts Brazil in Rio de Janeiro.

It was the sort of match that neither team deserved to lose, and for more than 120 minutes, it appeared neither team could be defeated. Both created chances, both had spells of superiority and both relied on the brilliance of their world-class keepers at key times.

Italy's last three knockout-round eliminations have all been against Spain (Euro 2008/2012, 2013 #ConfedCup).

Those goalkeepers, Spain's Iker Casillas and Italy's Gianluigi Buffon, were heroes before the shootout began. Both rank among the world's best, and both showed why with key saves in regular and extra time as the match finished scoreless.

But in the shootout, neither put a hand on any of the 14 shots. The only miss, from defender Leonardo Bonucci after six of his teammates had converted, flew harmlessly high above Casillas' net. Moments later Jesus Navas converted coolly to crush Italy's valiant resistance.

Robert Cianflone/Getty Images

And it was a memorable performance indeed.

Gone was the Azzurri defense that had conceded eight goals in three group-stage matches. In its place was an organized, disciplined unit any Italian could love. Prandelli's team rendered Spain’s famous passing game ineffective, pressuring the ball and closing down the space Spain customarily exploit for their endless passes.

It was, in short, the best Italian performance since the Euro 2012 semifinals, when the Azzurri stunned Germany to set up a date with Spain in the final. Spain won that one easily, dominating Italy 4-0 for their third straight major international title, but it became clear quickly Thursday night that no repeat was possible.

Spain dominated possession, as usual, in the first 45 minutes, but Italy produced more—and better—chances. Midfielder Antonio Candreva consistently carved out space on the right against Jordi Alba, and Italy enjoyed the advantages of attacking with width. Italy's Alberto Gilardino shot wide with Spain caught in transition, and Iker Casillas saved from Emanuele Giaccherini and Daniele De Rossi.

Robert Cianflone/Getty Images

But for all their chances, Italy failed to find the net. And with the mercurial Mario Balotelli injured, their game-changer from the Germany game last summer was unavailable for an encore performance.

The pace slowed in the second half, but Italy remained formidable. By full time, with the score still 0-0, the Azzurri had more possession and passing after the break, but Spain had more shots.

Both teams hit the post in extra time, Italy through Giaccherini in the first half and Spain via Xavi's swerving, dipping blast in the second. But still the score remained 0-0 as the match went to penalties.

There the luck was with Spain, but on another night fortune just as easily could have favored Italy.