The financially-stricken club, who will be banned from European competition for four years after this campaign, had just enough to edge past the Portuguese champions, who had to play most of the second half with ten men.
The impressive youngster Isco had given the home side the lead at half-time thanks to a thunderous effort from outside the area.
Steven Defour saw red just after the interval, receiving his second booking for a cynical challenge on Javier Saviola, and substitute Roque Santa Cruz made the extra man count, heading the winner late on to write his own chapter in the history of Malaga.
It was a scrappy start to the match, with the referee the busiest man on the pitch, producing several bookings in the opening stages as both sides struggled to get going.
The game sprang to life late in the half when Saviola thought he had given his side the lead, but it was harshly ruled out for a foul by Julio Baptista on Danilo.
However, moments later, the highly-rated Isco did send the home fans into raptures, firing an unstoppable shot when given too much space on the edge of the penalty area, leaving Helton with no chance.
Early in the second half Porto's task was made even more difficult when Defour inexplicably brought Joaquin down with a dangerous late challenge, which could have been a straight red in itself.
It was all hands to the pump after that, with Porto defending in numbers as they tried to force the tie to extra-time, with Jackson Martinez looking very isolated on his own up front.
It seemed only a matter of time until Manuel Pellegrini's men found a priceless winning goal, and it was his timely introduction of Santa Cruz that sent the unfancied men from southern Spain through.
Set-pieces were always going to be a struggle one-man down, and so it proved when the on-loan Manchester City striker headed an inviting outswinging corner past Helton to put his side on course for victory.
Martinez almost equalised from a sublime James Rodriguez free-kick, which he flicked just past the post, but nothing could deter the Spanish underdogs, and the celebrations on the whistle showed just how much it meant to the fans and players alike.