Rangers, who won the first-leg in Glasgow 2-0, were trailing 1-0 as the clocked ticked down in injury time. When the Dortmund goalkeeper went upfield to join the pursuit of an equaliser, he remarkably - and somewhat fortuitously - set up Fredi Bobic for the goal that took the tie into extra time.
Rangers held themselves together through the goalless extra half an hour but then fell apart when faced with the task of beating Lehmann from the penalty spot in the decisive shoot-out. The goalkeeper saved three spot kicks and Dortmund, the former European champions, were through.
A dejected Lorenzo Amoruso, the Rangers captain, said nothing went right. "It was a cruel way to lose. Everything went the other way for us today," he said. "They scored twice with the second goal in injury time. We lost two stupid goals, missed a great chance to score ourselves in extra time then were unfortunate with the penalties."
The Italian defender said Rangers must learn from the defeat. He said: "We realise that we need to improve because away from Ibrox I think we lose too many goals."
Rangers were firm favourites to progress after their first-leg victory, but they were always second best in the Westfalen stadium.
Their anticipated injury problems eased with Claudio Reyna, Jorg Albertz and Rod Wallace all proving themselves fit enough to start. By contrast Dortmund, without a win in 10 games, were without a several key players, including Jurgen Kohler, Andreas Moller, Giuseppe Reina and Evanilson.
Rangers created the first chance, after eight minutes, when Giovanni van Bronckhorst released Neil McCann, but his cross was easily taken by Lehmann.
Dortmund, fighting for the respect of their fans and for their survival of their young coach, Michael Skibbe, after a poor run of form, stepped up the pace and put Rangers on the back foot. They halved their aggregate deficit in the 29th minute when Christian Worns swung in a corner from the left. Although Thomas Myhre got a hand to Victor Ikpeba's header, he was unable to stop the ball going into the net.
Albertz, who had been having pain-killing injections on his ankle injury, did not reappear in the second half. He was replaced by Gordon Durie, with the former Scotland striker joining Wallace and McCann in the front line.
Dortmund had the majority of possession, and Amoruso had to steer away a goal-bound header from Otto Addo in the 63rd minute. But as the half progressed Rangers began to look more confident and Barry Ferguson broke forward only to drag his 20-yard shot wide.
Dortmund then sensationally pulled level on aggregate in stoppage time when their substitute, Bobic, knocked the ball home after it bounced to him from Lehmann. The goalkeeper had missed the ball with his own attempt at a shot, but it rebounded off his standing leg.
Durie, who worked hard with little return, released Andrei Kanchelskis in extra time, but his first touch was poor, and Lehmann was able to save comfortably. Rangers had a scare eight minutes into extra time when Bobic found himself in space but he blazed the ball high over the bar.
McCann should have given Rangers the lead on aggregate three minutes later. However, when Tony Vidmar played the ball into his path, he shot wide from almost on the goalline. Then Amoruso tested Lehmann with a powerful 35-yard free-kick after Ferguson had played the ball back to him.
There would be no breakthrough, though, and the tie went to penalty kicks. Rangers paid for their disappointing overall performance with Lehmann saving from Van Bronckhorst, Arthur Numan and Claudio Reyna, so Rangers went out despite Amoruso's success from the spot.
Borussia Dortmund: Lehmann; Reuter, Worns, Nijhuis, Stevic (Tanko, 72), Nerlinger, Ricken (Barbarez, 82), But, Addo, Herrlich (Bobic, 62), Ikpeba.
Rangers: Myhre; Moore, Amoruso, Adamczuk (Kanchelskis, 90), Numan, Reyna, Ferguson, Van Bronckhorst, Albertz (Durie, h-t), McCann, Wallace (Vidmar, 90).
Referee: Sarvan Oguz (Turkey).