Dos Santos netted an early opener for the home side on 6 minutes, then the Argentine ace equalized one minute later.
The minnows retook the lead on 18 minutes when Nabil Baha scored Malaga's second, and Real's up-and-coming lad leveled again on 36 minutes.
The 21-year-old completed a hat-trick on 70 minutes, but the recently-promoted side leveled within few seconds by Apono's strike.
Eventually, Higuain scored the winner nearly ten minutes from time to give Los Merengues all three points.
Having won the game, Bernd Shuster's men kept the second place with 23 points, trailing their arch-rivals Barcelona by two.
The victory is also a moral boost for the Spanish giants after being condemned to a 2-0 defeat by Juventus in the UEFA Champions League.
Exciting Clash
Dos Santos scored the opener when he dribbled past Real's defenders from the left wing. His first shot hit the post but he slotted home with scintillating follow-up effort.
Minutes later, Rafael van der Vaart cannoned a powerful shot that was denied by the keeper, and the in-form Higuain tucked into an empty net.
Moroco's Baha put Malage ahead again when he latched on to a left-flank cross, taking advantage of Gabriel Heinze's poor marking.
Higuain bagged his second when he converted a penalty kick that was signaled as a result of a handball.
The Spanish giants suffered a major setback when the referee red-carded Sergio Ramos after stepping onto Eliseu's chest in a rough challenge.
Despite their numerical disadvantage, the defending champions kept on fighting against their stubborn opponents.
After the interval, the hosts surpassed when Apono converted a penalty-kick, But again Higuain equalized with a long-range effort.
The Argentine forward scored the winning goal from a penalty-kick. The keeper parried the first shot but Higuain's follow-up was unstoppable.