Karim Benzema stopped Real Madrid's underwhelming La Liga season going from bad to worse on Sunday after firing a last-minute winner to hand the European champions a barely-deserved 3-2 winner over bottom club Huesca.
Humbled by Ajax in the Champions League and dumped out of the Copa Del Rey by deadly rivals Barca, third-placed Real showed little signs of improvement in Zinedine Zidane's second game in charge but Benzema, subject to rumours he may leave Madrid in the summer for Manchester United, struck with a fine curling finish the to snatch the three points at a sparsely populated Santiago Bernabeu.
"We are happy with him and I am going to count on him, now there are nine games left and then we will see what happens. He is a Real Madrid player and I don't think this will change," Zidane said.
"You have to accept it. If the people want to come to the Bernabeu to see us so much the better, but I understand that since we are not going to win anything fewer people come."
Real move to within two points of second-placed Atletico Madrid, who hammered Champions League hopefuls Alaves 4-0 on Saturday in a match that saw Diego Costa score for the first time since November.
However Real still lag 12 points behind leaders Barcelona, who are 10 clear of Atletico and heavy favourites to retain their La Liga after Lionel Messi fired them to their sixth league win on the bounce, 2-0 at home to local rivals Espanyol on Saturday, with a brace that took the Argentine to 31 league goals this season.
Zidane's son Luca was given his second ever start between the sticks for Real but got off to the worst possible start, picking the ball out of his own net within three minutes after Cucho Hernandez lashed home Ezequiel Avila low cross.
Isco levelled the scores in the 25th minute when he tapped home a Brahim Diaz cross after Benzema's low shot was well saved, but it was the away side -- playing their first ever La Liga game at the Madrid's Santiago Bernabeu stadium -- who went closer going into the break ahead.
Zidane junior had to be alert to stop Damian Musto from glancing home a header nine minutes before the break, while Avila punched the ground in frustration in first half stoppage time after flashing a power shot over from the edge of the box.
Real continued to disappoint in the second half but took the lead just after the hour mark thanks to Dani Ceballos, who bundled home the second after Gareth Bale's beautiful cross was headed back across goal by Benzema.
Bale then missed a glorious opportunity to put the game beyond Huesca when he somehow put Alvaro Odriozola's low cross over the bar from just yards out.
Huesca pounced on that awful miss to draw level when Xabier Etxeita powered home Moi Gomez's cross from a short corner.
However Benzema was on hand to break Huesca hearts with his 14th league goal of the season, which gives Zidane two wins from his first two matches back in charge.
Earlier Valencia maintained their hopes of a place in next season's Champions League after Daniel Parejo's penalty on the stroke of half-time gave them a vital 1-0 victory at Sevilla.
Parejo's spot-kick, which came after Ever Banega brought down Jose Gaya, extended Valencia's unbeaten run to nine matches and moves them up to sixth, level on 43 points with Sevilla and just three back from the final Champions League spot.
That place is occupied by Getafe, who fell 2-0 at home to mid-table Leganes on Saturday and have to play the league's top three and Sevilla in their final nine games.
Despite a slightly simpler league fixture list Marcelino's Valencia however have an all-Spanish Europa League quarter-final tie with Villarreal to contend with, as well as the Copa Del Rey final against Barcelona between now and the end of the season.