The Spanish giants produced a memorable 45 minutes to defeat Manuel Pellegrini's men after being 2-0 down at halftime, and are now favorites to reach the quarterfinals
After 10 minutes Sergio Sanchez rose highest to head Santi Cazorla's header into the net before the former Villarreal playmaker grabbed his second assist of the game when Martin Demichelis beat Iker Casillas to the ball to give his team a comfortable lead.
However, two goals in two minutes from Sami Khedira and Gonzalo Higuian saw the home team draw level before Karim Benzema grabbed the winner with 12 minutes left to play.
Both sides made cautious starts to the game yet on 10 minutes, Malaga shocked the hosts by taking the lead. Santi Cazorla whipped an inviting corner into the box from the left where Sergio Sanchez was on cue to firmly head the ball past Iker Casillas from six yards out - his first goal for the Andalusian outfit.
The second goal of the game fell to the visitors on 29 minutes, much to the dismay of the home support. Again, the assist was provided by Cazorla who curled his corner into the danger area with Martin Demichelis doing well to beat a lackluster Casillas to the ball to plant his header into the back of the net to give Manuel Pellegrini's side a deserved halftime lead.
The home side made a determined start to the second period and grabbed its just rewards in the 68th minute when a rare Sami Khedira strike made it 2-1. The German midfielder's driving run saw him power past the Malaga defense before smashing the ball past Cabellero for his second goal in the white shirt of Madrid.
Amazingly, two minutes later Mourinho's men were level after some shocking defending by Sanchez. The former Sevilla man's weak backpass was intercepted by Gonzalo Higuain who rounded the keeper before slotting home from a tight angle to put his side right back in the tie.
The comeback was complete in the 78th minute when Ronaldo's clever flick fooled the Malaga backline as Benzema ran clear to slide the ball past the helpless Cabellero to give his team the win on the night.
The two sides meet again on Jan. 10 at La Rosaleda, with a quarterfinal place in the Copa del Rey at stake.