Cristiano Ronaldo struck his first La Liga goal of the season five minutes from time to save Real Madrid from losing more ground in the title race with a hard-fought 2-1 win at Getafe on Saturday.
Real looked on course for a comfortable three points when Karim Benzema fired the visitors into a deserved half-time lead.
However, Jorge Molina's equaliser early in the second half and an incredible miss by Ronaldo left the European champions needing a late saviour.
And Ronaldo rode to the rescue and made amends for his earlier profligacy with an accurate volleyed finish into the far corner.
Victory takes Real up to second and within four points of Barcelona, who travel to Atletico Madrid later on Saturday.
Despite being shorn of Gareth Bale, Dani Carvajal and Keylor Navas through injury and illness, Zinedine Zidane surprisingly left Luka Modric and Isco on the bench after their exertions on international duty and with one eye on Tuesday's Champions League clash against Tottenham Hotspur.
However, that decision backfired as once again Zidane's men produced a lacklustre performance in La Liga.
Real dropped points at home to Valencia, Levante and Real Betis to allow Barcelona to open up a seven-point gap at the top of the table and even failed to find their top form in seeing off Alaves and Espanyol in recent weeks.
Part of Madrid's problem has been Ronaldo's poor league form since returning from an early season five-game suspension.
Ronaldo's first effort did at least produce a stunning save from Vicente Guaita as he drove Benzema's neat layoff goalward from the edge of the box.
Guaita was left helpless six minutes before half-time, though, when Benzema latched onto Ronaldo's pass and kept his composure to fire low into the far corner for his first league goal of the season.
Getafe had barely threatened before levelling in fortunate circumstances 11 minutes into the second half when Molina bundled home Francisco Portillo's low cross despite appearing to be in an offside position.
The equaliser awoke Real from their second-half slumber and Guaita produced another great double save to block at Ronaldo's feet before tipping Marcelo's follow-up effort over.
Ronaldo drilled a free-kick just wide, but his embarrassing moment was still to come 17 minutes from time.
With the goal at his mercy as the ball rebounded into his path from a free-kick, the Portuguese somehow skewed wide at the far post.
Zidane threw on Isco, Theo Hernandez and Borja Mayoral from the bench in the search for a winner.
And it was Isco who provided the inspiration as his through ball released Ronaldo to finally break his duck in La Liga for the season by firing into the far corner.
Getafe could still have salvaged a point in stoppage time when Mehdi Lacen's shot flew inches over with Real 'keeper Kiko Casilla stranded.
Real jump into second thanks to Sevilla's 1-0 defeat to Athletic Bilbao earlier on Saturday as Mikel Vesga got the only goal two minutes before half-time.