Gareth Bale scored an early winner as Real Madrid won 1-0 away to a spirited Huesca and moved up to fourth in La Liga, five points behind leaders Barcelona.
After an early scare that saw David Ferreiro head wide for the hosts, Madrid took the lead in style after eight minutes when Alvaro Odriozola crossed and Bale steered a cushioned volley past goalkeeper Aleksandar Jovanovic.
Huesca refused to be daunted by that early setback, threatening again when Thibaut Courtois was forced into action by Ezequiel Avila's effort.
Bale almost doubled Madrid's lead with a fierce strike from distance that was saved by Jovanovic in what was an open game despite windy conditions.
Dani Carvajal was booked for a challenge on the edge of his own area, only for the Huesca free kick to come to nothing, with the home side's Xabier Etxeita then booked for a foul on Bale as the first half came to a close.
The home side should have levelled within seconds of the second half beginning when former Madrid player Melero headed wide from close range.
They were almost punished when they backed off Lucas Vasquez as he set off on a surging run that ended with a blocked shot, but threatened again when Courtois tipped over a Ferreiro drive.
Madrid made a change, bringing on Federico Valverde for Dani Ceballos, and Bale forced another save with a 30-yard effort as the game reached the hour mark.
Huesca were continuing to have the better of the half, forcing a succession of corners but unable to find a route past Courtois, and Madrid made another change as Luka Modric was withdrawn to be replaced by Isco.
Bale was denied again when his angled effort was stopped by Jovanovic after a move that sprang from the home keeper's poor clearance, with the Wales international being replaced by Marco Asensio as the game entered its final 15 minutes.
Defender Jorge Pulido volleyed wildly over as time began to run out for Huesca, but they were unable to fashion an equaliser despite a dramatic goalmouth scramble in injury time.