Karim Benzema scored in the final minute of the match to snatch all three points for Real Madrid as they edged out bottom side Huesca 3-2 at the Bernabeu on Sunday evening.
Los Blancos were heading towards another embarrassing result on home soil until their French striker curled the ball home to deny Huesca a huge point in their fight for survival.
The visitors put up a brave battle in the Spanish capital, taking a shock lead through Juan Camilo Hernandez early on and then battling back to 2-2 after Isco and Dani Ceballos had turned the game on its head.
It was not to be in the end, however, as Real made it two wins from two under returning boss Zinedine Zidane to move back to within two points of second-placed Atletico Madrid.
© Reuters
On their first visit to the Bernabeu, it took the visitors less than three minutes to open the scoring as Ezequiel Avila won back the ball from Nacho on the right and picked out Hernandez, whose sweeping first-time finish was past Luca Zidane before the goalkeeper could react.
All Real could offer in response over the next 15 minutes was a couple of shots from Benzema, one forcing Roberto Santamaria into a routine save and the other flying wide.
Real managed to get back on level terms through Isco's second goal since Zidane returned, following up his strike in the 2-0 win against Celta Vigo two weeks ago with a simple close-range finish here.
Benzema carried the ball forward and exchanged passes with Brahim Diaz, before getting a shot away that Santamaria could only push as far as Isco.
The home side took control of possession for the rest of the first half, but the closest either team came to a second goal before the interval was Huesca through Avila.
© Reuters
The Argentine attacker trapped the ball with his first touch but rocketed it over the crossbar from a good position with his second.
Real's players left the field to jeers at the end of the first half, and they continued into the second when Gareth Bale - the player most strongly targeted by those in the stands - fired a free kick high and wide.
Benzema tested Santamaria for a second time with his shot towards the bottom corner and, with a little over an hour played, Los Blancos had a lead to hold on to.
Bale's sublime outside-of-the-boot cross was headed across goal by Benzema and Ceballos, who started the attack from deep, threw himself at it near the back post to get on the scoresheet.
Both teams came close soon after as Yangel Herrera fizzed one wide and Bale, having played a big part in his side's second goal, somehow guided Alvaro Odriozola's cross over the crossbar at full stretch from four yards out.
© Reuters
For a short while that looked to be a costly miss as Huesca skipper Xabier Etxeita peeled away from Nacho to guide Moi Gomez's short corner into the bottom corner of the net.
A tame attempt from Lucas Vazquez aside, Real did not offer a great deal between Huesca's leveller and Benzema's eventual winner, with the Frenchman using a couple of players as a wall to curl the ball into the bottom corner.
REAL MADRID (4-3-3): Zidane; Odriozola, Nacho, Ramos, Marcelo; Isco (Valverde 75'), Llorente (Mariano 79'), Ceballos; Bale, Benzema, Diaz (Vazquez 64')
HUESCA (5-3-2): Santamaria; Herrera, Etxeita, Mantovani, Pulido, Galan; Musto, Gomez, Rivera (Juanpi 78'); Avila (Enric 63'), Hernandez (Gallar 82')
No Data Analysis info