Deportivo La Coruna welcomed Real Madrid on Saturday knowing that three points would have moved them off the bottom of the table.
The home side opened the scoring after 35 minutes when Riki found the back of the net, with that scoreline still standing at the interval.
Madrid improved in the second period, however, and were level 20 minutes from time when Kaka curled an effort into the top corner.
There was still time for late drama, as Gonzalo Higuain tapped home in the final minute to secure all three points for Madrid.
Read how it all unfolded in Sports Mole's minute-by-minute live commentary of the action below.
DEPORTIVO: Aranzubia; Marchena, Ayoze, Kaka, Silvio; Valeron, Aguilar, Assuncao, Riki; Gama, Pizzi
REAL MADRID: Lopez; Arbeloa, Carvalho, Pepe, Marcelo; Modric, Essien, Kaka; Di Maria, Higuain, Callejon