Cristiano Ronaldo struck on the rebound after his penalty was saved to give Real Madrid a 3-2 victory over Malaga in their LaLiga clash at the Bernabeu.
With leaders Barcelona set to play at second-placed Valencia on Sunday night, Zinedine Zidane's men were looking to make the most of their opportunity to eat into a 10-point deficit.
All looked to be going to plan when Karim Benzema put the home side ahead after just nine minutes, only for Diego Rolan to equalise.
Real Madrid were soon back in front when Casemiro headed in a corner after 21 minutes.
Gonzalo Castro levelled up again early in the second half with a 30-yard effort, but Ronaldo had the final say when lashing home with 14 minutes left after his spot-kick had been stopped.
Benzema, who scored twice in the 6-0 Champions League win over APOEL Nicosia, nodded in the early opener from close range after Ronaldo's header came back off the crossbar.
Isco, who joined Real from Malaga in the summer of 2013, and defender Dani Carvajal then both had efforts saved by Roberto.
The visitors were back on level terms after 18 minutes.
Midfielder Toni Kroos played a ball back into the Real Madrid penalty area, which was seized on by Sergio Keko. He got to the byline and clipped a pass back to Rolan which the Uruguay forward took on his chest before drilling into the bottom corner.
Real, though, regained the lead just three minutes later. German Kroos made amends as he clipped a corner into the Malaga six-yard box, where Brazilian Casemiro powered in a towering header.
Before Saturday's game, Benzema had not scored at home since mid-August. He missed a chance to extend the lead after 30 minutes when played clear by Isco, as the French forward dragged his shot wide.
Roberto made an acrobatic save from Lucas Vazquez, before clawing away a goal-bound header from Ronaldo.
Malaga had the ball in the net at the end of first-half stoppage time as substitute Paul Baysse looped in a header following a free-kick, but the referee had blown his whistle just moments earlier.
Real threatened again early in the second half when Kroos' side-footed shot was heading for the top corner before Roberto produced another fine save.
The visitors equalised again after 58 minutes. Castro let fly from 30 yards and his shot dipped late, with Kiko Casilla only able to push the ball into the bottom corner.
Ronaldo failed to connect with a flick from Raphael Varane at the far post.
However, in the 74th minute, substitute Luka Modric was hauled down in the penalty area by Luis Hernandez.
Ronaldo stepped up for the resulting spot-kick, which Roberto saved, but the ball dropped straight back to the Portuguese frontman who smashed it into the roof of the net.
Roberto Rosales dragged a chance for Malaga wide, before Ronaldo saw a late effort incorrectly ruled out for offside.