Real are now three points clear and have a game in hand despite Antoine Griezmann's classy finish five minutes from time snatching a 1-1 draw for Atletico Madrid earlier at the Santiago Bernabeu.
However, Real can now afford to lose to Barca at home in two weeks' time and still have a first title in five years in their own hands.
Neymar picked up the first red card of his Barcelona career for two bookable offences as the Catalans were left to rue letting Sandro Ramirez join Malaga for free last summer.
Malaga also had the better chances of the second-half filled with controversy as Juanpi shot straight at Ter Stegen when clean through.
More From This Section
Neymar had been shown his first booking for delaying a Malaga free-kick whilst tying his shoelaces and stupidly charged into Diego Llorente 25 minutes from time to see red.
The hosts then had a goal wrongly ruled out for offside when substitute Adalberto Penaranda finished off a flowing counter-attack.
However, Barca were also infuriated with referee Gil Manzano when he somehow awarded a free-kick on the edge of the box when Sergi Roberto had been brought down clearly inside the area.
Real let-off
============
Barca's defeat meant Real's disappointment earlier in the day was short lived.
Pepe's towering header early in the second half looked to have Real heading five points clear at the top in the Madrid derby.
However, Griezmann rounded Keylor Navas to slot home at the near post five minutes from time.
After a slow start, Real took control of the game as the first half wore on and only two stunning stops prevented Zidane's men from taking a half-time lead.
Moments later Cristiano Ronaldo couldn't believe his eyes when his fierce goal-bound effort was turned to safety by Stefan Savic's incredible headed clearance from under his own crossbar.
Real started the second half with intent as Ronaldo headed just wide before Oblak had to rush from his goal to block Benzema's volley from point-blank range.
The European champions finally made the breakthrough seven minutes into the second period when Pepe rose highest in a crowded penalty area from Toni Kroos's free-kick to power a header into the far corner.
The former Spanish international failed to finish, though, as he fired straight at the onrushing Navas.
Navas has faced a barrage of criticsm this season, but he made another smart stop to deny Griezmann levelling with an outrageous overhead kick attempt.
The French international wasn't to be denied from an excellent through ball from Angel Correa with five minutes remaining, however, as he coolly fired past the advancing Navas at the near post for his 23rd goal of the season.