Karim Benzema was the late hero as Real Madrid won the second successive game under returning boss Zinedine Zidane, with a battling 3-2 victory of bottom of the table Huesca.
The Frenchman his 15th La Liga goal of the season, two minutes from time to seal all three points, curling home 15 yards after Marcelo deflected Gareth Bale's left wing cross into his path.
Relegation battling Huesca had threatened to pull off a major shock in the opening stages, as Juan Hernandez fired them in front after just four minutes.
However, Ziddane's side rallied quickly and Isco netted his second goal in two games, slotting home from close range after Benzema's shot was parried by Roberto Santamaria.
The hosts started the second half with real purpose, and Dani Ceballos scored a scrappy goal on 62 minutes after Benzema headed another fine Bale delivery into his stride.
Huesca skipper Xabier Etxetia had looked to have secure a point for the the away side as he headed home from a corner on 74 minutes, however Benzema had the final say.