Late Cazorla free-kick stuns leaders Real
Real moved on to 71 points with 11 matches left to play but after 11 straight victories saw their lead cut to eight points, champions Barcelona having beaten Sevilla 2-0 away on Saturday.
Karim Benzema had headed Real in front after 35 minutes but the visitors refused to crumble under some intense pressure and Spain international Cazorla grabbed a deserved equaliser in time added on.
Big-spending Malaga, who were bought by a member of the Qatari royal family two years ago, were fifth with 41 points.
"We wanted to stay in the game and with only one goal against us anything was possible," Cazorla told Spanish television.
"I'd already gone close in the first half but at the end there it went in. A victory was vital for our objectives."
Real came out wearing shirts in support of Barcelona's Eric Abidal, who is set to have a liver transplant, and Bolton Wanderers midfielder Fabrice Muamba, who collapsed after suffering a cardiac arrest during a game in England on Saturday.
Malaga matched the hosts in a high-tempo opening until France striker Benzema arrived unmarked at the back post to nod in Cristiano Ronaldo's cross.
Jose Mourinho's men created a host of chances, La Liga top scorer Ronaldo being denied by a flying save from Willy Caballero and Benzema blazing wide from six metres out.
Cazorla was brought down on the edge of the area by Esteban Granero in the 92nd minute and the former Villarreal player left Iker Casillas with no chance.
Earlier, striker Roberto Soldado scored a hat-trick as Valencia ran out 3-0 winners at Europa League rivals Athletic Bilbao to strengthen their hold on third place.
Soldado, who is in the running for a place in the Spain squad at Euro 2012, pounced on a poor back-pass to net the opener and struck a first-time shot after the break for the second.
He racked up his 15th of the campaign from the penalty spot near the end.
Bilbao struggled to replicate the eye-catching form that helped them knock Manchester United out of the Europa League last week. They were missing the injured Fernando Llorente and had defender Andoni Iraola sent off in the 66th minute.
Valencia moved on to 47 points, six ahead of fourth-placed Levante, who continued to defy predictions with a 1-0 victory at home to regional rivals Villarreal.
Xavi Torres scored in the 92nd minute and caused Villarreal to sack their coach Jose Molina. They lie 17th with 27 points, three above the relegation places.
Bilbao were seventh with 37 points, one ahead of Atletico Madrid in ninth.
Ten-man Real Mallorca overcame Atletico 2-1 at home, the match turning in a crazy 10 minutes at the start of the second half.
Atletico's Diego Godin put into his own net in the 47th, Michael Pereira doubled the lead two minutes later and the islanders had defender Ivan Ramis sent off for handball in the 53rd.
Mallorca's Dudu Aouate saved the ensuing penalty from Radamel Falcao, though the Colombia striker responded with an outstanding lob to pull one back for the visitors in the 66th.