Spain needed a 73rd minute goal from defender Carles Puyol to edge past Germany 1-0 on Wednesday and set up a World Cup final against Netherlands.
Puyol climbed above the defence to head the winner from a Xavi corner and send Spain to their first World Cup final.
The Spaniards dominated most of the match but struggled to finish off a German side that was lacking their usual pace.
European champions Spain dominated possession early on and needed only five minutes to carve out their first chance against a nervous German defence.
Spain forward Pedro, who started ahead of the misfiring Fernando Torres, played the ball for David Villa, who caught Arne Friedrich napping but could not beat keeper Manuel Neuer.
With the Germans, who lost the Euro 2008 final to the Spaniards by the same score, boxed into their own half, Spain kept up the pressure, with Puyol heading an Andres Iniesta cross from the right narrowly over the bar after 15 minutes.
Germany's Piotr Trochowski, who replaced the suspended Thomas Mueller on the right, stretched Spain goalkeeper Iker Casillas with a well-struck low drive.
Pedro and Sergio Ramos continued to single out Germany left back Jerome Boateng as a weakness, cutting the ball back from the wing for midfielder Xabi Alonso who twice fired wide early in the second half.
The Spaniards came agonisingly close in the 58th minute with a Pedro shot that forced a spectacular save from Neuer before Iniesta cut the ball across the face of goal a metre ahead of the sliding Villa.
Germany remained on the backfoot and 17 minutes from time were punished when Puyol headed home the winner.
Spain will face Netherlands at Soccer City in Johannesburg on Sunday. The Dutch have been in the final twice before but have never won it so a new world champion is guaranteed.