Federico Valverde's stunning stoppage-time strike kept Real Madrid in the La Liga title hunt as Carlo Ancelotti's side eventually overcame stubborn Athletic Bilbao at the Bernabeu.
Valverde crashed an emphatic half-volley into the top corner with the outside of his left foot three minutes into time added on to finally reward incessant second-half pressure from the hosts.
It was his sixth league goal this season, but first since December against Sevilla.
Victory kept Real, who were without France striker Kylian Mbappe as he served a one-match ban following a red card in the 1-0 win at Alaves, four points behind leaders Barcelona with six games to go.
Barca had produced their own added-time drama on Saturday, coming from 3-1 down to beat Celta Vigo 4-3 thanks to Raphinha's 98th-minute penalty.
However, after a humbling week that saw the Champions League holders dumped out of this year's competition with a 5-1 aggregate defeat by Arsenal, Real kept alive their hopes of retaining their league title.