Bayern, who won the Bundesliga title on Sunday, had captain Philipp Lahm and Xabi Alonso slip as they sent their penalties into the stands as the Munich side missed all four of their efforts after a 1-1 draw following extra time.
Dortmund, beaten finalists last season, took revenge and maintained their hopes of a Europa League spot next term through the Cup competition after a disappointing Bundesliga campaign.
Unlucky Bayern will now focus on the Champions League where they face Barcelona in the last four next week.
“I did not expect such a game,” beaming Dortmund coach Juergen Klopp told reporters.
“I wanted us to play with more courage in the first half and I told my players that it is ok to lose here but not with this nonsense. Let's go down fighting,” added Klopp, who is leaving the club at the end of the season.
Yet it had all looked to be going in Bayern's favour with their former Dortmund striker Robert Lewandowski scoring for the third time against his old club when he drilled home on the rebound in the 30th minute.
The Poland international then hit the post in the second half as Bayern dominated and looked certain to enjoy more goals.
But a quick break sent Dortmund's Pierre-Emerick Aubameyang through at the far post and the Gabon forward slid in for the equaliser in the 75th against the run of play.
It was the wake-up call Dortmund needed and twice they had the chance to score again as the game turned on its head but Bayern goalkeeper Manuel Neuer's superb reflexes denied Marco Reus and Henrikh Mkhitaryan.
Bayern then lost winger Arjen Robben, who had come on as a substitute following a stomach muscle injury last month but lasted only 16 minutes.
“We played a great game and in the first half they had no chance,” Bayern coach Pep Guardiola said. “We had some problems for five or seven minutes. I am very proud of my team.
“As for the penalties, this happens. Penalties are always about controlling emotions and maybe we were a bit tired.”
Dortmund were reduced to 10 men in extra time following the dismissal of Kevin Kampl but kept their cool and keeper Mitch Langerak made the save of the game by stopping Bastian Schweinsteiger's point-blank header.
They then converted two penalties, as Bayern's hopes were dashed when their first two takers missed after slipping before Mario Goetze's spot kick was saved and Neuer rattled the bar. – Reuters
Original source: Dortmund ruin Bayern’s treble hopes