The Spaniards, who drew 0-0 in the first leg, stunned the 66,000 crowd in Dortmund when Joaquin shook off his markers and drilled in a low shot for the lead in the 25th minute.
Dortmund striker Robert Lewandowski drew the hosts level in the 40th minute and they squandered a string of chances in the second half with Reus and Mario Goetze.
Trailing 2-1 as three minutes of added time began, Dortmund equalised through Marco Reus but Malaga still held the away goals advantage.
That all changed, however, when Felipe Santana scored from what looked to be an offside position following a goal-mouth scramble in the last minute of play, setting off scenes of delirium among the local team and crowd.
"I think I need to see a doctor. It feels like we've won the trophy," Dortmund coach Juergen Klopp said. "My assistants and me were looking at each other in shock in the dressing room and saying, 'This is crazy'. This is the best I've ever felt".
The German side, which surrendered its Bundesliga title to Bayern Munich on Saturday, remains the only unbeaten side left in the competition. Dortmund last reached the semifinals in 1998, the year after it won the title.
Under coach Manuel Pellegrini, Malaga was trying to become the first team to reach the semifinals in its first Champions League campaign since Villarreal in 2006, also coached by Pellegrini.
"We're still trying to come to terms with what happened," Malaga forward Roque Santa Cruz said. "We were four minutes away from the semis. There is huge disappointment in the dressing room. We had the tie in our hands".
|Weekly consumption of oily fish rich in ... The essential omega-3 fatty acid abundant in oily fish ...|