Wales forward Gareth Bale scored the winner as Real Madrid moved back into La Liga’s top four with a hard-fought victory at bottom side Huesca.
Bale ended a run of 10 matches without a goal in Spain’s top flight with a sumptuous side-footed volley.
Huesca should have equalised after the break, but Gonzalo Melero headed wide from close range.
Bale saw a chipped effort diverted just wide, while Juan Camilo Hernandez fired over for Huesca as Real hung on.
Thibaut Courtois tipped a Moi Gomez free-kick over the bar in injury time, and Dani Carvajal headed a Christian Rivera effort off the line from the resulting corner.
Huesca, who are in their first season in La Liga, matched Real’s four efforts on target, and for long periods outplayed their more illustrious opponents.
Indeed, the visitors only managed two shots on target in the second half – their lowest return in all competitions this season – and Karim Benzema failed to register a single effort for the first time this campaign.
However, after Melero’s glaring miss, Huesca failed to create another chance of similar quality, and also found Courtois in good form. The Belgian had made a series of important interventions before his 92nd-minute stop to deny Gomez, most notably an acrobatic save from David Ferreiro’s 57th-minute drive, to keep a third clean sheet in a row.
Victory for Santiago Solari’s side leaves them five points behind leaders Barcelona, who thrashed city rivals Espanyol 4-0 on Saturday.
They next play on Wednesday, at home to CSKA Moscow in the Champions League, having already secured a place in the knockout round.