The holders won thanks to Karim Benzema's strike 12 minutes from time, after Sergio Sanchez and Martin Demichelis put Malaga on course for a win in the capital with goals in the 10th and 29th minutes.
Sami Khedira (68) and Gonzalo Higuain (70) brought Mourinho's team level before France forward Benzema netted the winner, although they still have a tough job on their hands to win the tie.
Real coach Jose Mourinho said: "Our performance in the first half was not good. We lacked concentration and made big mistakes in set pieces, but my team cleaned its own trash thanks to the support of the crowd. It isn't easy to find such support when you're losing. We came back thanks to the bond between team and audience, and we'll have the advantage in Malaga."