BASEL, Switzerland - Philipp Lahm ended Turkey's storybook run in the European Championship on Wednesday by scoring a 90th-minute goal to give Germany a 3-2 semifinal victory and keep it on target for a record fourth title.

With two goals in the final five minutes, the match could have gone either way, but after three thrilling comeback victories in a row for Turkey, it was Germany's day.

First, Semih Senturk kept Turkey in the game with an 86th-minute equalizer. He beat Jens Lehmann at the near post after surging in to deflect a low cross from Sabri Sarioglu, who had fooled Lahm with a classy move.

With the Turkish fans celebrating wildly, Lahm immediately sought and found redemption to decide a classic game. He cut in from left, set up a one-two with Thomas Hitzlsperger, collected the ball and shot it past Rustu Recber to unleash the joy of about 20,000 German fans at St. Jakob Park.

"It unleashed all that joy. It was my most important goal," said Lahm, especially since it came immediately after his error. "In the moments leading up to 2-2, I certainly looked bad. It happens to me too."

And after so many thrilling finishes at the championships. this one topped it all.

"Totally crazy feeling," Germany coach Joachim Loew said. "It was unbelievable. It was a crazy, incredible drama with all these goals in the final minutes."

Turkey has had its share of crazy finishes, too, scoring late to beat Switzerland and the Czech Republic in the first round, and then getting a late goal to force penalties against Croatia in the quarter-finals.

"It was very tough to come back after 2-2. They always score in the last minute," Loew said. "It showed that we have the right mentality. It was a class goal to settle it."

In the first half, Ugur Boral gave Turkey the lead in the 22nd minute, but Bastian Schweinsteiger equalized in the 26th minute.

Miroslav Klose seemed to have closed out the match for Germany in the 79th minute. Lahm sent a long cross into the penalty area, where Klose cut in front of Mehmet Topal and a hopelessly out of position Recber to head into the empty net.

"When we conceded an easy goal it was difficult for a young team to come back," Turkey coach Fatih Terim said.

The Germans, however, were not counting on the resilience of a Turkish team which never gives up. But this time, even Senturk's second late goal in as many matches was not enough. Germany, too, is long known as a team which plays full-out until the final whistle.

Still, six years after getting to the semifinals of the World Cup, Turkey is back.

"It showed the world what a good team we are. We are leaving as the most colourful team," Terim said.

Germany will play the winner of Thursday's second semifinal match between Spain and Russia in Vienna on Sunday.

"Good luck for the final," Terim said.

Turkey dominated long spells of the match despite four suspensions and five injuries, proving its run of extraordinary comeback victories was no fluke.

"I said I would have 11 players on the field and I did," Terim said.

With a fully fit team, Germany struggled throughout as captain Michael Ballack could not inspire the forward line.

"We had no clear line in our game," Loew said.

Turkey was inspirational, though.

Taking a cross from the right, Kazim Kazim slid in front of defender Per Mertesacker and sent a looping shot past Lehmann onto the bar. Boral was waiting for the rebound and rifled it through the goalkeeper's legs.

Grapple and grasp as Lehmann might, the ball bounced over the line and yet another upset win seemed in the making.

The Turks have proved the comeback kids throughout the tournament but holding an early lead proved impossible.

"We just fell short of the final," Terim said.

Germany instead showed off its legendary efficiency by scoring on its first chance of the match four minutes later. Podolski broke away on the left and sent a perfect low cross to Bayern teammate Schweinsteiger in the centre.

With an almost nonchalant flick of the outside right foot, he beat Topal to the ball and curled it past Recber.

"Efficiency, this is what we had today," Loew said.