The Spanish side looked to be going through when Eliseu put them 2-1 up with eight minutes remaining, before Marco Reus equalised and then Felipe Santana broke Spanish hearts in a thrilling climax.
Malaga took the lead when Joaquin rolled the ball in after 25 minutes, before Robert Lewandowski levelled the scores before half time.
But the away goal saw Dortmund become increasingly desperate, and Malaga looked to have qualified for the last four until the hosts' willpower saw them home.
Following the goalless draw in the first leg, the German side had looked confident early in the match until going behind totally against the run of play, Isco knocking the ball down to Joaquin who rolled the ball past Roman Weidenfeller's left hand.
Dortmund were rocked on their heels, but gradually regrouped and levelled the scores five minutes before the break. Reus' superb back-heeled flick wrong-footed the Malaga defence, allowing Lewandowski to race in on goal and chip the ball over Malaga keeper Willy.
Joaquin could have put Malaga further ahead twice, either side of the break, taking advantage of sloppy defending but each time putting his headers too close to Weidenfeller.
The Dortmund keeper also punched away a rasping shot from Toulalan as the Spanish side, in the Champions League for the first time this season, pressed hard to make the semi-finals.
That looked to be on the cards when they stunned the typically noisy BVB Stadion with eight minutes to go. Isco and Baptista combined to allow Eliseu to tap the ball in from close range, although there was a hint of offside about the substitute's goal.
But the German side, favourites to go through before the tie, steeled themselves and then stunned their opponents with two goals in stoppage time.
Felipe Santana caused enough of a nuisance for the ball to arrive with Reus, who levelled the scores with a simple chance.
And with Malaga's away goals still counting against them, Dortmund threw everything into one last attack that paid off in style when Santana got to Julian Schieber's mis-hit shot inches from the line to win the tie.
Replays showed that the goal should have been flagged for offside, but it stood to give the much-fancied German side the chance of making their second Champions League final.