Luka Modric's sensational strike helped Real Madrid scrape a late 2-1 win at struggling Granada.
Karim Benzema put Zinedine Zidane's men ahead on the half-hour mark, but the hosts refused to wilt and got a deserved equaliser when Youssef El Arabi poked the ball through Keylor Navas' legs.
Modric had given the ball away for the equaliser after colliding with the referee, but made amends by winning the match late on with a breathtaking finish.
In the build-up to this game, head coach Zidane said victory was vital if Madrid wanted to stay in the title race - keeping them four points behind league leaders Barcelona, who have a game in hand, and a point off neighbours Atletico Madrid.
Real only beat Sunday's opponents 1-0 earlier in the season and Granada gave another stern display back in Andalusia, where they started impressively.
Adalberto Penaranda nearly crept into the box after chasing a through ball, but Navas raced out of his area and kicked the ball away. The Granada forward then put the ball in the net after it was returned to him, but he was well offside.
Cristiano Ronaldo had Madrid's first attempt, coming down the left and hitting a low shot that just missed the target.
Madrid had struggled to get the ball moving around midfield, but they took the lead thanks to Isco's precision pass out to Dani Carvajal, who cut inside and cut the ball back for Benzema to tap in at the near post.
It was the sixth consecutive league game the French striker had scored in - his best scoring run in a white shirt - but Granada continued to look dangerous and could have levelled just before the break, when David Barral came into the box, only for Raphael Varane to intercept.
Toni Kroos provided an equally important block at the start of the second half, getting in the way of a shot from the impressive Isaac Success, before Navas tipped away a point-blank range header from Barral.
Benzema twice wasted chance to double his tally, shooting into the side netting before goalkeeper Andres Fernandez thwarted him.
The save was as important as it was impressive as Granada levelled less than a minute later.
Modric collided with the referee Jesus Gil Manzano around the halfway line, allowing Ruben Rochina to recover the ball and quickly give it to El Arabi, who calmly knocked it between Navas' legs.
Granada deserved to be level and could have taken the lead when Success again burst into the box, but again the Costa Rica goalkeeper got there first, leaving the attacker to appeal half-heartedly for a penalty.
Madrid looked out of ideas at the other end but were rescued by a moment of brilliance from Modric.
The Croatia midfielder received the ball outside the area from compatriot Mateo Kovacic and took a couple of touches before picking his spot, rifling into the opposite corner to secure victory.