Zinedine Zidane was made to sweat on his landmark 100th outing as Real Madrid manager in a late 2-1 win against Getafe at the Coliseum Alfonso Perez.
Los Blancos' seven-match winning run against their city rivals looked to be coming to an end after Jorge Molina cancelled out Karim Benzema's first-half opener.
Cristiano Ronaldo popped up to rescue his side late on with his first league goal of the season, though, netting shortly after missing a sitter to lift his side up to second place in the La Liga table on a landmark occasion for Zidane.
The hosts struggled to really get going for large parts of the first half, seeing a couple of Ronaldo shots routinely kept out by Vicente Guaita in the Getafe goal.
Faycal Fajr had the Dark Blues' only on-target attempt of the half, forcing a simple save out of back-up stopper Kiko Casilla - filling in for the injured Keylor Navas - while Molina headed over from a good position.
Madrid hold claim to having the best away record in the Spanish top flight this term and it was not long before they clicked into gear, with Benzema being thwarted with a near-post shot and Lucas Vazquez having a volley blocked aside.
The breakthrough moment then arrived 39 minutes in when Benzema intercepted the ball and charged through, knocking it past sliding defender Juan Cala and smartly tucking beyond the reach of Guaita.
Benzema, himself without a league goal in three outings this term, also skied a shot over the bar as Los Blancos went into the break sitting a goal to the good.
The second half panned out in a similar manner, as Zidane's men bossed possession but struggled to do a great deal with it and were almost made to pay.
Shortly after Guaita pulled off a double save to deny Ronaldo and a half-fit Marcelo, Molina picked out the net at the other end of the field when reacting quickest to get the faintest of touches to a right-sided cross.
Marcos Llorente got a touch to help the ball into the centre-forward's path, making it five goals in eight outings for him against the defending champions.
Ronaldo skewed the ball wide when picked out unmarked at the back post for one of the worst misses of his career, somehow failing to find the back of the net from just a couple of yards out.
Zidane turned to Isco and Theo Hernandez from the bench for the final quarter of the game, with the latter doing what Ronaldo could not by beating Guaita, only for the offside flag to go up.
Mauro Arambarri almost made himself a local hero by finding a winner late on, but he failed to even test Casilla after being picked out in a promising position, and that would prove to be a big moment in the match.
Ronaldo, with 20 previous career goals against Getafe, got on the end of Isco's cross and rifled superbly past Guaita on this occasion to save his side with five minutes left to play.