Philipp Lahm's last-minute winner sent Germany into the Euro 2008 final and sank a desperately unlucky Turkey.
Lahm stole in on Thomas Hitzlsperger's pass to beat Rustu Recber and give the Germans victory after a thriller in which Turkey were the better side.
Ugur Boral scrambled Turkey ahead after 22 minutes, but Bastian Schweinsteiger equalised quickly from close range.
Miroslav Klose headed Germany in front after 79 minutes, but Semih Senturk levelled before Lahm's late strike.
Germany barely deserved the victory, but once again they have reached a major final despite being unconvincing, where they will face either Russia or Spain in Vienna on Sunday.
Ravaged by injuries and suspension, Turkey defied all expectations to produce an outstanding performance full of grit, desire and no little quality and they should have been well in front by half-time.
He was denied by the woodwork again with a looping finish 10 minutes later - but this time Ugur was lurking to scramble in the rebound through the legs of the despairing Lehmann.
Stunned by the speed of Turkey's opening, Germany responded to equalise after 27 minutes.
Lukas Podolski was the creator with a run and cross from the left flank, but it needed a sweet finish with the outside of Schweinsteiger's right foot to beat Rustu.
Lehmann was having a nightmare and he had to scramble back hurriedly after misjudging Hamit Altintop's free-kick to turn the ball over the bar.
It was a superb spectacle, and Podolski escaped the attentions of the Turkish defence only to shoot over the top with Klose waiting unmarked in front of goal.
Lehmann was then forced to punch Ugur's powerful free-kick away after 39 minutes as Turkey continued to show the greater ambition.
Germany coach Joachim Low made a change at the interval, replacing Simon Rolfes, who had suffered a head wound in a clash with Ayhan Akman, with Torsten Frings.
The Germans were furious after 50 minutes when Lahm was clearly felled by Sabri Sarioglu, only to see Swiss referee Massimo Busacca ignore their appeals.
But Turkey, under the inspirational leadership of coach Fatih Terim, were continuing to set the pace and Ugur tested Lehmann once more with a shot at the end of a fine run.
Hitzlsperger showed the shooting power that marked his time at Aston Villa with 18 minutes left, shooting just wide from 30 yards with Rustu beaten.
But it was a calamitous error by the veteran Rustu that gifted Germany the lead with 11 minutes left, when he came for Lahm's cross but got nowhere near it, leaving Klose to head Germany in front.
If this tournament has told us one thing, it is that Turkey's refusal to accept defeat means they are at their most dangerous when behind and so it proved again as they drew level again with four minutes left.
Sabri rounded Lahm superbly on the flank, and the poacher Semih stole in to beat Lehmann at the near post.
Turkey looked to have taken the game into extra time, which was the very least they deserved, but their campaign ended in heartbreak in the closing moments.
Lahm raided forward and exchanged passes with Hitzlsperger before firing high past Rustu.
Germany celebrated the victory, but so much credit must go to Turkey for a magnificent effort that deserved so much more.
Germany: Lehmann, Friedrich, Mertesacker, Metzelder, Lahm, Hitzlsperger, Rolfes (Frings 46), Schweinsteiger, Ballack, Podolski, Klose (Jansen 90).
Subs Not Used: Enke, Adler, Fritz, Westermann, Gomez, Neuville, Trochowski, Borowski, Odonkor, Kuranyi.
Goals: Schweinsteiger 27, Klose 79, Lahm 90.
Turkey: Rustu, Sarioglu, Topal, Zan, Balta, Aurelio, Kazim-Richards (Metin 90), Altintop, Akman (Erdinc 81), Boral (Karadeniz 84), Senturk.
Subs Not Used: Zengin, Cetin, Emre, Gungor, Nihat.
Goals: Boral 22, Senturk 86.
Ref: Massimo Busacca (Switzerland).