Top-ranked Spain won 7-6 on penalty kicks after the teams failed to score in 90 minutes of regulation play and a further half hour of extra time at the Estadio Castelao in Fortaleza.
The final of the two-week Confederations Cup, an eight-nation warmup for next year’s World Cup, will be played June 30 at the Maracana Stadium in Rio de Janeiro.
The win extends the unbeaten run for world and European champion Spain to a record 29 competitive games, two more than the mark set by France in 1999.
After the first 12 penalty kicks in the shootout were successful, Leonardo Bonucci blasted his effort over the bar. Jesus Navas then slid the ball into the lower left corner of the net to seal the win for Spain.