Just as it looked as though Malaga had done it, Dortmund scored twice in injury time through Reus and Felipe Santana, who himself appeared to be offside.
Here, Sports Mole analyses the action to see whether the right team went through.
On target 7
On target 5
Was the result fair?
Based on the fact that it would have been exceptionally harsh had Dortmund gone out on away goals, the right team did just about go through. They had much more of the ball and created more chances in all, but the last-ditch manner of the win will leave a bitter taste in Spanish mouths.
They didn't start playing until Malaga had opened the scoring, but after then they showed in spells why they are one of the most exciting attacking teams in Europe. Their defence left a lot to be desired as aside from the goals Malaga were left with free headers on several occasions but were unable to capitalise.
They did just about everything they could have done, but fell agonisingly short. The game plan was clear: to soak up the pressure and score on the break. They managed to do so twice - albeit the second goal should have been disallowed - but eventually the German possession told. The winning goal was also offside, but Malaga should not have let them score twice in injury time.
Sports Mole's man of the match
Marco Reus: Had Malaga gone on to win this might well have gone to Martin Demichelis, but for his impact on everything Dortmund did in attack this has to go to Reus. His flick to Lewandowski set up the first goal and he was in the right place for the equaliser. A constant thorn in the side of an otherwise impressive Malaga defence.
Take your pick from any of the bizarre officiating decisions. First Marcel Schmelzer should have been shown a second yellow card for slapping Jesus Gamez, but instead the defender was booked for his reaction. Then the flag did not go up for Eliseu's goal when he was offside before the linesman on the other side did not see that Santana had only one man in front of him when the ball was played in for his winner.
For the reasons mentioned above, it wasn't the best day at the office for Scotland's Craig Thomson. He can only really be blamed for the Schmelzer decision, of course, but he also oddly booked Sven Bender inside 10 minutes for his first foul.
Dortmund: Dortmund return to league action at the weekend having already had their title wrestled away from them by Bayern Munich. They travel to Greuther Furth looking to stay on top in the race for second place.
Malaga: It will be tough for Malaga to bounce back but they now have a battle to qualify for the Champions League next season, if UEFA still allows them to play in the competition. They'll want to beat Osasuna at home on Saturday to stay in the hunt for fourth place.